Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate OneToMany with ORA-02291 error

 
James Dinho
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a problem when persist an entity with its childs in OneToMany relationship. Here my two entity:


And now the persist operation that generate ORA-02291 error:



What can i do to fix the problem?

Thanks to everyone!
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't seem to see where you initialize AddressPK in the Address record.

Without that, all Address records would have the same (null) key.
 
James Dinho
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I did it to simplify the post.



Hope this help you. Thanks
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something that might make things a little easier to work with.

When defining an entity (or entityPK) object, you ALWAYS have to provide a no-element constructor. But you can also supply your own constructors. So for example:



And


Not meant to accurately reflect your code, just as an example.

If you're using multiple columns in your child ID, be careful. Compound keys in JPA can be a real pain. And you cannot have any of the key column values be null.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic