[
http://jira.jboss.com/jira/browse/JBAS-5105?page=comments#action_12393943 ]
Dr. Richard Li commented on JBAS-5105:
--------------------------------------
Using the following procedures can reproduct the problem:
1. Create an Entity Bean with self gen keys using SERIAL type.
2. Use a session bean to create a few instances of the Entity Bean.
3. Exception occurs, only 1 row is created successfully, but other rows keep failing.
I try to trace the SQL and figure out the problem is not that simple, the correct sequence
in doing the create is:
1. insert the row into the table (NEED to OPT OUT the PK FIELD)
2. use currval('the_sequence') to retrieve the actual pk
but actually the sequence is:
1. use currval('the_sequence') to obtain the pk
2. set the pk in the entity
3. insert the row in the table (The pk field is set as well)
This sequence have the following problems:
1. The pk value may be the same in multiple threads execution which cause duplicate key
exception
2. the sequence will not increment since the pk field is given an actual value. When next
time the value of the sequence is enquired an exception will occurs.
I would like to contribute on this issue, could any body points out that if I can use the
correct sequence with the current framework? I this is the case, I can work on.
PostgreSQL Entity Command for jdbc2pm is Not Working Properly
-------------------------------------------------------------
Key: JBAS-5105
URL:
http://jira.jboss.com/jira/browse/JBAS-5105
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: CMP service
Affects Versions: JBossAS-4.2.2.GA
Environment: PostgreSQL 8.2, Windows XP Pro
Reporter: Dr. Richard Li
Assigned To: Alexey Loubyansky
Priority: Critical
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira