This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One to Many relationship not inserting to one table

 
Nirenj George
Greenhorn
Posts: 1
Hibernate Java Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I am new to Grails. There are 2 tables names 'Vessel' and 'Comment'. Each vessel records can have multiple comments posted by different users. When user saves any Vessel record along with any Comments, Vessel data must be saved to Vessel table and each Comment must be saved to Comment table with reference to record in Vessel table.

Now the problem is that once I call the save button, my app only inserts record into Vessel table and does not insert any records into Comment table. I have given one-to-many relationship.

Please advice whether I need to do any extra steps to make sure both tables get data inserted, or is there anything I am missing here. I am using Grails 1.3.7.

Thanks a lot in advance.





 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code you have thus far looks good (albeit with some outdated steps but not detrimental). However, you didn't how / tell us how your 2 domain objects are getting populated in the first place.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic