• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

One to Many relationship not inserting to one table

 
Greenhorn
Posts: 1
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.





 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic