|
Hello,
I'm facing problems, when I persist JPA entities. Here is scenario: I'm using CDI, and inject EntityManager and UserTransaction into named bean. I have entity, that we can call MainEntity. It has 2 "@ManyToOne(optional = false, fetch = LAZY, cascade = { PERSIST, REFRESH })" relationship to other entities, lets call them MinorEntity. So, when i commit UserTransaction, the JPA first of all inserts Main, then MinorEntity, and then try to update MainEntity table again. The problem is, that i have not null constraint on database. I googled a little bit, and found that i should use OpenJPA @ForeignKey annotation, to force OpenJPA first of all insert MinorEntity. But this didn't helped to me, the insert order is still incorrect. The strangest thing, is that i have unit test, that tries to simulate this situation using Resource Local transaction type. And it does not fails. What I'm doing wrong? Is there need, to do some additional Geronimo app server configuration? Here is persistence.xml of container managed persistence context: <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> And here is persistence.xml of resource local persistence context: <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> Please help, because if I will not be able to solve this soon, I will be forced to move to some another JPA implementation, or even another APP server. Admirolas |
|
I am thinking that this is not Geronimo specific issue, forward your email to openjpa user mail list, there are many experts there :-)
2012/3/26 Adme Admirolas <[hidden email]> Hello, Ivan |
| Powered by Nabble | Edit this page |
