You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Midyat <Mi...@hotmail.com> on 2010/05/11 12:05:53 UTC

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

im am using hsqldb 2.0.0 rc9 and open jpa-2.0.0
My code sample is here:
http://rapidshare.com/files/385991203/201005111201_SpringJPA2_-_works_but_first_entry_in_db_crashes.rar

Please only focus at the "storing of data"-part.
I know the "retrieval of data-part" is a bit messy, but that's not the
problem. 
Just execute the main a first time, and you will see the problem. 
FYI: when running the main, i also had to pass this VM
-javaagent:C:\Eclipse\workspace\jpa\lib\openjpa-all-2.0.0.jar

Do you see the problem?
Thanks!
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5035236.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
Try adding a version field to each of your Entities.

@Version
int version;

-- 
Thanks,
Rick

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
The changes are included in the 2.1.0 snapshot build[1] from last night.

[1]http://openjpa.apache.org/downloads.html

On Wed, May 12, 2010 at 5:03 PM, Rick Curtis <cu...@gmail.com> wrote:

>
> You're right, it looks like I messed up and sent you the old code. I need
> to run quickly here, so either you can try to build openjpa yourself
> tonight, or you can wait for the nightly build and pickup the changes
> tomorrow. Sorry about the runaround.
>
> Thanks,
> Rick
>

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
You're right, it looks like I messed up and sent you the old code. I need to
run quickly here, so either you can try to build openjpa yourself tonight,
or you can wait for the nightly build and pickup the changes tomorrow. Sorry
about the runaround.

Thanks,
Rick

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Midyat <Mi...@hotmail.com>.
I'm very sorry.
I removed openjpa-all-2.0.0.jar from buildpath.
I added your sandbox build pttebt.jar to the buildpath.
Same result. Thanks for all effort, but it doesn't work.
The same issue as originally reported is still there.

-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5043403.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
I committed a change to trunk. I also posted a sandbox build with the change
to filebin[1] if you would like to give that a try.

[1]http://filebin.ca/pttebt

Thanks,
Rick

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.

Midyat wrote:
> 
> You can add my code example as attachment to the bug in JIRA.
> Because the link on rapidshare will be deleted in a few days.
> 

I'm working on a fixing the problem right now. I should have a change
committed later this afternoon.

http://issues.apache.org/jira/browse/OPENJPA-1665

--
Thanks,
Rick
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5042439.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Midyat <Mi...@hotmail.com>.
You can add my code example as attachment to the bug in JIRA.
Because the link on rapidshare will be deleted in a few days.
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5040522.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Midyat <Mi...@hotmail.com>.
I started already thinking that it was a bug, because the issue looks very
weird.
Thanks for investigating and confirming that it's a bug. 

I don't have a JIRA account to report a bug. 
Maybe you can do it?
Can you please let me know how/where I can track the bug? 

PS: It's very annoying if you download a library and the very first thing
you try to do fails because of a bug.  
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5040519.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
I was finally able to recreate your problem... this is an OpenJPA code bug
having to do with generated ids that start with zero.

As a work around for now, you could use GenerationType.AUTO for your
StatusUpdate.id column.

Please open a JIRA for this problem. If you don't have an account, let me
know and I'll do it.

-- 
Thanks,
Rick

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Midyat <Mi...@hotmail.com>.
Thank you so much for trying to help, but unfortunately adding the @version
field to the entities brings no help. 
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5037685.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Midyat <Mi...@hotmail.com>.
yes it starts with 0
i was also looking in that direction to find a solution, but unfortunately i
could not find how to make it start with another value. (the tables should
be automatically generated by persistence.xml)

FYI: I run HSQLDB as follows. Write it down for maybe in the future, because
it also took me more then an hour to find it out. 
    - start database server:
C:\java_libs\hsqldb-2.0.0-rc9\hsqldb-2.0.0-rc9\hsqldb>java -cp
./lib/hsqldb.jar org.hsqldb.server.Server -database.0 file:mydb -dbname.0
xdb
    - start database manager:
C:\java_libs\hsqldb-2.0.0-rc9\hsqldb-2.0.0-rc9\hsqldb>java -cp
./lib/hsqldb.jar org.hsqldb.util.DatabaseManager
      and connect to the above started database server with URL:
jdbc:hsqldb:hsql://localhost/xdb
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5037540.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: An object of type "src.StatusUpdate" with oid "0" already exists in this context; another cannot be persisted.

Posted by Rick Curtis <cu...@gmail.com>.
I wasn't able to get hsqldb in-mem working so I used MySQL and everything
worked fine (as far as I can tell). This is the output that I got with
MySQL:
ok
ok
ok
active
deactive

I'm just shooting in the dark here, but the first time that you run this
application, does the first auto generated id start with a zero by any
chance?

-- 
Thanks,
Rick
-- 
View this message in context: http://openjpa.208410.n2.nabble.com/An-object-of-type-src-StatusUpdate-with-oid-0-already-exists-in-this-context-another-cannot-be-persi-tp5030272p5036148.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.