• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Exception when adding a child in one-to-many

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Quick situation overview - I've got an entity called a PartHolderNode which has a collection of entities called RepositoryItems. I'm trying to add an existing RepositoryItem into an existing PartHolderNode's collection. Instead of a slightly bigger collection, I get an exception stating "Unable to commit". The mapping seems to be correct based on the fact that if I add a new (not persisted) RepositoryItem to a collection and call merge it persists to the database as expected.

Detail -

Inside a stateless controller bean for PartHolderNodes I had the following method -


manager.persist() has also been tried as manager.merge().

Unfortunately, this results in the following -


The JBoss logs show that it has executed an update to the join table between the two entities, but when it attempts to "close PreparedStatement" it throws the JDBCException stating "Could not execute JDBC batch update".

Surely adding an element to a collection and saving the change to the db should be straightforward? What have I missed this time?!


The relationship between PHN and RIs is mapped as follows -



and the addFile(foo) method in the controller bean just consists of files.add(foo.)

If you need any more detail just let me know.
[ May 17, 2007: Message edited by: Ross Hendry ]
 
Ross Hendry
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved by changing the relationship to a @ManyToMany like it should be. Doh!
 
We can fix it! We just need some baling wire, some WD-40, a bit of duct tape and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic