This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

two parents, one child, ora-02291

 
Pablo Marmol
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have a simple issue about parent/child relations. Something is wrong when i persist three instances at same transaction, that is, one child and two parents. The child have ManyToOne relations to the parent1 and the parent2, and the two parents have one OneToMany relation (each one) to the child. The child table have two foreign keys to its parents. This is the code:

Parent1:


Parent2:


Child:


And this is the code that use the entities:


In my investigation about this i find that this works when the child have only one parent.

I try another way: I drop de FK constraints in the database, then i execute the code, and then i recreated the FK constraints... and voila!!! no errors creating the FK constraints ?¿?¿?¿?¿? That signals that the data is right, but anything is wrong and i dont understand... Could you help me please?

I use java 6, weblogic 10.3.4 (jpa 1 i think), oracle 11.

Thank you very very much... i'm obfuscated.
 
Pablo Marmol
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More info:

The code is executed within an EJB, using EntityManager and container-managed transactions.
Using Postgresql is the same.
The code works on glassfish3 adding "allocationSize = 1" to the "@SequenceGenerator" annotations. But in WLS 10.3.4 don't works. Glassfish3 comes with JPA2, and WLS 10.3.4 only JPA1, but i'm not using anything of v2.

searching... (thanks in advance)
 
Pablo Marmol
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solved.

Add this to persistence.xml:
<properties>
<property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
</properties>

Enjoy.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic