Topic topic = new Topic()
topic.name = "y u no save"
topic.save(flush:true, failOnError:true)
def promiseList = new PromiseList()
subtopicNames.each { sName ->
promiseList << Topic.async.task {
Subtopic subtopic = new Subtopic()
subtopic.name = sName
/* ... long running tasks like web service call ... */
log.info("Topic Id : $topic.id")
subtopic.topic = topic
subtopic.save(flush: true, failOnError: true)
}
}
def subtopics = promiseList.get() Detail: Key (topic_id)=(517333) is not present in table "topic".; nested exception is org.postgresql.util.PSQLException: ERROR: insert or update on table "subtopic" violates foreign key constraint "fkfd7d3e7098cf2d58"
Detail: Key (topic_id)=(517333) is not present in table "topic". Topic -
class Topic {
String name
static hasMany = [subtopics: Subtopic]
}
Subtopic -
class Subtopic {
String name
static belongsTo = [topic: Topic]
}Hibernate operation: could not execute statement; SQL [n/a]; ERROR: insert or update on table "sub_topic" violates foreign key constraint "fkfd7d3e7098cf2d58"
Looks like the underline sql query is not affected even on calling insert.
> email to grails-dev-discuss+unsub...@googlegroups.com.
>> > email to grails-dev-discuss+unsub...@googlegroups.com.
>> > To post to this group, send email to grails-de...@googlegroups.com.
>> > To view this discussion on the web visit
>> >
>> > https://groups.google.com/d/msgid/grails-dev-discuss/d9b5ed23-f5e3-486c-88b1-8820caae1e7a%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Graeme Rocher
>
> --
> You received this message because you are subscribed to the Google Groups
> "Grails Dev Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to grails-dev-discuss+unsub...@googlegroups.com.