openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin <benjamin.ren...@gmail.com>
Subject Re: Problem using OpenJPAEntityManager#createInstance
Date Thu, 13 Nov 2008 17:10:20 GMT

Hi Pinaki,

Thanks for the suggestion! It was very helpful. 

Before moving on to the next issue, can you confirm that all the manual
repository calls I am making is the right way to go?

I am now running into a different issue.

I am using DB-driven primary key allocation (@Id
@GeneratedValue(strategy=GenerationType.IDENTITY))

When I persisted my first instance, there was no problem. When I try to
persist my second (and third, and fourth...) I get the following error:

Caused by: <openjpa-1.2.0-r422266:683325 fatal user error>
org.apache.openjpa.util.InvalidStateException: Attempt to set column
"TestPerstInterface.id" to two different values: (class java.lang.Long)"0",
(class java.lang.Long)"301" This can occur when you fail to set both sides
of a two-sided relation between objects, or when you map different fields to
the same column, but you do not keep the values of these fields in synch.

Needless to say I am not setting the ID by hand. A quick debugging session
shows that OpenJPA tries to populate the ID with 0 first, then with the
generated ID and trips itself up.

Any idea if I am doing something wrong, or how to get past this? It appears
that not generating the ID and setting it by hand doesn't work either.

Thanks!!
Benjamin


Pinaki Poddar wrote:
> 
> Hi,
>   Looks like a potential bug. The problem seems to be that OpenJPA is not
> creating the OPENJPA_SEQUENCE_TABLE (a special table used by OpenJPA to
> auto-generate primary key) for Managed Interfaces.
>   Try creating the OPENJPA_SEQUENCE_TABLE separately. The instructions to
> create this table is available in main() method's JavaDoc in [1]
> 
> [1]
> http://openjpa.apache.org/builds/latest/docs/javadoc/org/apache/openjpa/jdbc/kernel/TableJDBCSeq.html
> 
> 

-- 
View this message in context: http://n2.nabble.com/Problem-using-OpenJPAEntityManager-createInstance-tp1493116p1494702.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.


Mime
View raw message