[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Optimistic Lock Exception expected
|
Hi,
Enclosed, you'll find the source code of the entity/main class and log
output:
@Entity
public class SimpleEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String value;
@Version
private Long version;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
if (!(object instanceof SimpleEntity)) {
return false;
}
SimpleEntity other = (SimpleEntity) object;
if ((this.id == null && other.id != null) || (this.id != null
&& !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "eclipselinktest.SimpleEnity[id=" + id + "]";
}
public class Main {
private static EntityManagerFactory emf;
public static void main(String[] args) {
JpaHelper.getServerSession(getEntityManagerFactory()).getProject().assumeExistenceForDoesExist();
SimpleEntity entity = new SimpleEntity();
entity.setValue("entity");
//persist "entity" and create clone "entityCopy"
EntityManager em1 =
getEntityManagerFactory().createEntityManager();
em1.getTransaction().begin();
em1.persist(entity);
em1.getTransaction().commit();
SimpleEntity entityCopy = em1.find(SimpleEntity.class,
entity.getId());
em1.close();
//delete "entity" from database
EntityManager em2 =
getEntityManagerFactory().createEntityManager();
em2.getTransaction().begin();
entity = em2.merge(entity);
em2.remove(entity);
em2.getTransaction().commit();
em2.close();
//merge clone "entityCopy" and commit
EntityManager em3 =
getEntityManagerFactory().createEntityManager();
em3.getTransaction().begin();
entityCopy = em3.merge(entityCopy);
em3.lock(entityCopy, LockModeType.WRITE);
em3.getTransaction().commit();
em3.close();
}
private static EntityManagerFactory getEntityManagerFactory() {
if (emf == null) {
emf =
Persistence.createEntityManagerFactory("EclipseLinkTestPU");
}
return emf;
}
LOG OUTPUT:
===========
[EL Finest]: 2009-04-16
10:57:45.749--ServerSession(20248218)--Thread(Thread[main,5,main])--Begin
predeploying Persistence Unit EclipseLinkTestPU; state Initial;
factoryCount 0
[EL Finest]: 2009-04-16
10:57:45.776--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.weaving;
value=false
[EL Finest]: 2009-04-16
10:57:45.776--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.orm.throw.exceptions;
default value=true
[EL Finer]: 2009-04-16
10:57:45.776--ServerSession(20248218)--Thread(Thread[main,5,main])--Searching
for default mapping file in file:/root/workspace/EclipseLinkTest/src/
[EL Finer]: 2009-04-16
10:57:45.779--ServerSession(20248218)--Thread(Thread[main,5,main])--Searching
for default mapping file in file:/root/workspace/EclipseLinkTest/src/
[EL Config]: 2009-04-16
10:57:45.904--ServerSession(20248218)--Thread(Thread[main,5,main])--The
access type for the persistent class [class
eclipselinktest.SimpleEntity] is set to [FIELD].
[EL Config]: 2009-04-16
10:57:45.904--ServerSession(20248218)--Thread(Thread[main,5,main])--The
alias name for the entity class [class eclipselinktest.SimpleEntity] is
being defaulted to: SimpleEntity.
[EL Config]: 2009-04-16
10:57:45.907--ServerSession(20248218)--Thread(Thread[main,5,main])--The
table name for entity [class eclipselinktest.SimpleEntity] is being
defaulted to: SIMPLEENTITY.
[EL Config]: 2009-04-16
10:57:45.944--ServerSession(20248218)--Thread(Thread[main,5,main])--The
column name for element [private java.lang.Long
eclipselinktest.SimpleEntity.id] is being defaulted to: ID.
[EL Config]: 2009-04-16
10:57:45.945--ServerSession(20248218)--Thread(Thread[main,5,main])--The
column name for element [private java.lang.String
eclipselinktest.SimpleEntity.value] is being defaulted to: VALUE.
[EL Config]: 2009-04-16
10:57:45.945--ServerSession(20248218)--Thread(Thread[main,5,main])--The
column name for element [private java.lang.Long
eclipselinktest.SimpleEntity.version] is being defaulted to: VERSION.
[EL Finest]: 2009-04-16
10:57:45.951--ServerSession(20248218)--Thread(Thread[main,5,main])--End
predeploying Persistence Unit EclipseLinkTestPU; state Predeployed;
factoryCount 0
[EL Finer]: 2009-04-16
10:57:45.952--Thread(Thread[main,5,main])--JavaSECMPInitializer -
transformer is null.
[EL Finest]: 2009-04-16
10:57:45.952--ServerSession(20248218)--Thread(Thread[main,5,main])--Begin
predeploying Persistence Unit EclipseLinkTestPU; state Predeployed;
factoryCount 0
[EL Finest]: 2009-04-16
10:57:45.952--ServerSession(20248218)--Thread(Thread[main,5,main])--End
predeploying Persistence Unit EclipseLinkTestPU; state Predeployed;
factoryCount 1
[EL Finest]: 2009-04-16
10:57:45.955--ServerSession(20248218)--Thread(Thread[main,5,main])--Begin
deploying Persistence Unit EclipseLinkTestPU; state Predeployed;
factoryCount 1
[EL Finest]: 2009-04-16
10:57:45.97--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.logging.level;
value=FINEST; translated value=FINEST
[EL Finest]: 2009-04-16
10:57:45.971--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.logging.level;
value=FINEST; translated value=FINEST
[EL Finest]: 2009-04-16
10:57:45.971--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.user;
value=root
[EL Finest]: 2009-04-16
10:57:45.971--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.password;
value=xxxxxx
[EL Finest]: 2009-04-16
10:57:46.844--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.driver;
value=com.mysql.jdbc.Driver
[EL Finest]: 2009-04-16
10:57:46.844--ServerSession(20248218)--Thread(Thread[main,5,main])--property=eclipselink.jdbc.url;
value=jdbc:mysql://10.16.46.243:3307/jpatest
[EL Info]: 2009-04-16
10:57:46.847--ServerSession(20248218)--Thread(Thread[main,5,main])--EclipseLink,
version: Eclipse Persistence Services - 1.1.0.r3634
[EL Finest]: 2009-04-16
10:57:47.168--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.InformixPlatform,
RegularExpression: (?i)informix.*.
[EL Finest]: 2009-04-16
10:57:47.169--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.PointBasePlatform,
RegularExpression: (?i)pointbase.*.
[EL Finest]: 2009-04-16
10:57:47.169--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.DB2Platform,
RegularExpression: (?i).*db2.*.
[EL Finest]: 2009-04-16
10:57:47.169--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.SQLServerPlatform,
RegularExpression: (?i)microsoft.*.
[EL Finest]: 2009-04-16
10:57:47.169--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.PostgreSQLPlatform,
RegularExpression: (?i)postgresql.*.
[EL Finest]: 2009-04-16
10:57:47.169--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.SybasePlatform,
RegularExpression: (?i)(sybase.*)|(adaptive server enterprise.*)|(SQL
Server).
[EL Finest]: 2009-04-16
10:57:47.17--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.JavaDBPlatform,
RegularExpression: (?i).*derby.
[EL Finest]: 2009-04-16
10:57:47.17--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.oracle.Oracle10Platform,
RegularExpression: (?i)oracle.*.
[EL Finest]: 2009-04-16
10:57:47.17--Thread(Thread[main,5,main])--DBPlatform:
org.eclipse.persistence.platform.database.MySQLPlatform,
RegularExpression: (?i)mysql.*.
[EL Fine]: 2009-04-16
10:57:47.171--Thread(Thread[main,5,main])--Detected Vendor platform:
org.eclipse.persistence.platform.database.MySQLPlatform
[EL Config]: 2009-04-16
10:57:47.195--ServerSession(20248218)--Connection(15734641)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.227--ServerSession(20248218)--Connection(11511434)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.228--ServerSession(20248218)--Connection(31375837)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.26--ServerSession(20248218)--Connection(12590745)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.26--ServerSession(20248218)--Connection(18414151)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.295--ServerSession(20248218)--Connection(810652)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.295--ServerSession(20248218)--Connection(1537969)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.327--ServerSession(20248218)--Connection(18306724)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.327--ServerSession(20248218)--Connection(20526817)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.363--ServerSession(20248218)--Connection(4973260)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.363--ServerSession(20248218)--Connection(1503089)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.394--ServerSession(20248218)--Connection(15855697)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Config]: 2009-04-16
10:57:47.395--ServerSession(20248218)--Connection(30969271)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
platform=>MySQLPlatform
user name=> "root"
datasource URL=> "jdbc:mysql://10.16.46.243:3307/jpatest"
))
[EL Config]: 2009-04-16
10:57:47.428--ServerSession(20248218)--Connection(1352077)--Thread(Thread[main,5,main])--Connected:
jdbc:mysql://10.16.46.243:3307/jpatest
User: root@cerebrum
Database: MySQL Version: 5.1.23-ndb-6.2.15a-cluster-com
Driver: MySQL-AB JDBC Driver Version:
mysql-connector-java-5.1.6 ( Revision: ${svn.Revision} )
[EL Finest]: 2009-04-16
10:57:47.459--ServerSession(20248218)--Thread(Thread[main,5,main])--sequencing
connected, state is Preallocation_Transaction_NoAccessor_State
[EL Finest]: 2009-04-16
10:57:47.459--ServerSession(20248218)--Thread(Thread[main,5,main])--sequence
: preallocation size 50
[EL Finest]: 2009-04-16
10:57:47.459--ServerSession(20248218)--Thread(Thread[main,5,main])--sequence
SEQ_GEN: preallocation size 50
[EL Info]: 2009-04-16
10:57:47.516--ServerSession(20248218)--Thread(Thread[main,5,main])--file:/root/workspace/EclipseLinkTest/src/-EclipseLinkTestPU
login successful
[EL Finest]: 2009-04-16
10:57:47.537--ServerSession(20248218)--Thread(Thread[main,5,main])--Execute
query DataModifyQuery(sql="CREATE TABLE SIMPLEENTITY (ID BIGINT NOT
NULL, VALUE VARCHAR(255), VERSION BIGINT, PRIMARY KEY (ID))")
[EL Fine]: 2009-04-16
10:57:47.538--ServerSession(20248218)--Connection(12590745)--Thread(Thread[main,5,main])--CREATE
TABLE SIMPLEENTITY (ID BIGINT NOT NULL, VALUE VARCHAR(255), VERSION
BIGINT, PRIMARY KEY (ID))
[EL Finest]: 2009-04-16 10:57:47.567--Thread(Thread[main,5,main])--The
table (SIMPLEENTITY) is created.
[EL Finest]: 2009-04-16
10:57:47.568--ServerSession(20248218)--Thread(Thread[main,5,main])--Execute
query DataModifyQuery(sql="CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50)
NOT NULL, SEQ_COUNT DECIMAL(38), PRIMARY KEY (SEQ_NAME))")
[EL Fine]: 2009-04-16
10:57:47.568--ServerSession(20248218)--Connection(11511434)--Thread(Thread[main,5,main])--CREATE
TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38),
PRIMARY KEY (SEQ_NAME))
[EL Finest]: 2009-04-16
10:57:47.571--ServerSession(20248218)--Thread(Thread[main,5,main])--Execute
query DataReadQuery(sql="SELECT * FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN'")
[EL Fine]: 2009-04-16
10:57:47.571--ServerSession(20248218)--Connection(12590745)--Thread(Thread[main,5,main])--SELECT
* FROM SEQUENCE WHERE SEQ_NAME = SEQ_GEN
[EL Finest]: 2009-04-16
10:57:47.575--ServerSession(20248218)--Thread(Thread[main,5,main])--Execute
query DataModifyQuery(sql="INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT)
values ('SEQ_GEN', 0)")
[EL Fine]: 2009-04-16
10:57:47.575--ServerSession(20248218)--Connection(11511434)--Thread(Thread[main,5,main])--INSERT
INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values (SEQ_GEN, 0)
[EL Finest]: 2009-04-16
10:57:47.576--ServerSession(20248218)--Thread(Thread[main,5,main])--End
deploying Persistence Unit EclipseLinkTestPU; state Deployed; factoryCount 1
[EL Finer]: 2009-04-16
10:57:47.602--ServerSession(20248218)--Thread(Thread[main,5,main])--client
acquired
[EL Finest]: 2009-04-16
10:57:47.605--UnitOfWork(18135083)--Thread(Thread[main,5,main])--PERSIST
operation called on: eclipselinktest.SimpleEnity[id=null].
[EL Finer]: 2009-04-16
10:57:47.606--ClientSession(21443983)--Connection(810652)--Thread(Thread[main,5,main])--begin
transaction
[EL Finest]: 2009-04-16
10:57:47.606--ClientSession(21443983)--Thread(Thread[main,5,main])--Execute
query DataModifyQuery(sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT +
#PREALLOC_SIZE WHERE SEQ_NAME = #SEQ_NAME")
[EL Fine]: 2009-04-16
10:57:47.608--ClientSession(21443983)--Connection(810652)--Thread(Thread[main,5,main])--UPDATE
SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
bind => [50, SEQ_GEN]
[EL Finest]: 2009-04-16
10:57:47.611--ClientSession(21443983)--Thread(Thread[main,5,main])--Execute
query ValueReadQuery(sql="SELECT SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME
= #SEQ_NAME")
[EL Fine]: 2009-04-16
10:57:47.611--ClientSession(21443983)--Connection(810652)--Thread(Thread[main,5,main])--SELECT
SEQ_COUNT FROM SEQUENCE WHERE SEQ_NAME = ?
bind => [SEQ_GEN]
[EL Finest]: 2009-04-16
10:57:47.613--ClientSession(21443983)--Connection(810652)--Thread(Thread[main,5,main])--local
sequencing preallocation for SEQ_GEN: objects: 50 , first: 1, last: 50
[EL Finer]: 2009-04-16
10:57:47.613--ClientSession(21443983)--Connection(810652)--Thread(Thread[main,5,main])--commit
transaction
[EL Finest]: 2009-04-16
10:57:47.614--ServerSession(20248218)--Connection(810652)--Thread(Thread[main,5,main])--local
sequencing preallocation is copied to preallocation after transaction commit
[EL Finest]: 2009-04-16
10:57:47.614--UnitOfWork(18135083)--Thread(Thread[main,5,main])--assign
sequence to the object (1 -> eclipselinktest.SimpleEnity[id=null])
[EL Finer]: 2009-04-16
10:57:47.618--UnitOfWork(18135083)--Thread(Thread[main,5,main])--begin
unit of work commit
[EL Finer]: 2009-04-16
10:57:47.623--ClientSession(21443983)--Connection(18306724)--Thread(Thread[main,5,main])--begin
transaction
[EL Finest]: 2009-04-16
10:57:47.625--UnitOfWork(18135083)--Thread(Thread[main,5,main])--Execute
query InsertObjectQuery(eclipselinktest.SimpleEnity[id=1])
[EL Fine]: 2009-04-16
10:57:47.627--ClientSession(21443983)--Connection(18306724)--Thread(Thread[main,5,main])--INSERT
INTO SIMPLEENTITY (ID, VALUE, VERSION) VALUES (?, ?, ?)
bind => [1, entity, 1]
[EL Finer]: 2009-04-16
10:57:47.638--ClientSession(21443983)--Connection(18306724)--Thread(Thread[main,5,main])--commit
transaction
[EL Finer]: 2009-04-16
10:57:47.64--UnitOfWork(18135083)--Thread(Thread[main,5,main])--end unit
of work commit
[EL Finer]: 2009-04-16
10:57:47.64--UnitOfWork(18135083)--Thread(Thread[main,5,main])--resume
unit of work
[EL Finest]: 2009-04-16
10:57:47.66--UnitOfWork(18135083)--Thread(Thread[main,5,main])--Execute
query ReadObjectQuery(referenceClass=SimpleEntity sql="SELECT ID, VALUE,
VERSION FROM SIMPLEENTITY WHERE (ID = ?)")
[EL Finer]: 2009-04-16
10:57:47.661--UnitOfWork(18135083)--Thread(Thread[main,5,main])--release
unit of work
[EL Finer]: 2009-04-16
10:57:47.661--ClientSession(21443983)--Thread(Thread[main,5,main])--client
released
[EL Finer]: 2009-04-16
10:57:47.661--ServerSession(20248218)--Thread(Thread[main,5,main])--client
acquired
[EL Finest]: 2009-04-16
10:57:47.661--UnitOfWork(2799187)--Thread(Thread[main,5,main])--Merge
clone with references eclipselinktest.SimpleEnity[id=1]
[EL Finest]: 2009-04-16
10:57:47.662--UnitOfWork(2799187)--Thread(Thread[main,5,main])--The
remove operation has been performed on: eclipselinktest.SimpleEnity[id=1]
[EL Finer]: 2009-04-16
10:57:47.662--UnitOfWork(2799187)--Thread(Thread[main,5,main])--begin
unit of work commit
[EL Finer]: 2009-04-16
10:57:47.662--ClientSession(11001145)--Connection(4973260)--Thread(Thread[main,5,main])--begin
transaction
[EL Finest]: 2009-04-16
10:57:47.664--UnitOfWork(2799187)--Thread(Thread[main,5,main])--Execute
query DeleteObjectQuery(eclipselinktest.SimpleEnity[id=1])
[EL Fine]: 2009-04-16
10:57:47.664--ClientSession(11001145)--Connection(4973260)--Thread(Thread[main,5,main])--DELETE
FROM SIMPLEENTITY WHERE ((ID = ?) AND (VERSION = ?))
bind => [1, 1]
[EL Finer]: 2009-04-16
10:57:47.668--ClientSession(11001145)--Connection(4973260)--Thread(Thread[main,5,main])--commit
transaction
[EL Finer]: 2009-04-16
10:57:47.669--UnitOfWork(2799187)--Thread(Thread[main,5,main])--end unit
of work commit
[EL Finer]: 2009-04-16
10:57:47.669--UnitOfWork(2799187)--Thread(Thread[main,5,main])--resume
unit of work
[EL Finer]: 2009-04-16
10:57:47.669--UnitOfWork(2799187)--Thread(Thread[main,5,main])--release
unit of work
[EL Finer]: 2009-04-16
10:57:47.669--ClientSession(11001145)--Thread(Thread[main,5,main])--client
released
[EL Finer]: 2009-04-16
10:57:47.669--ServerSession(20248218)--Thread(Thread[main,5,main])--client
acquired
[EL Finest]: 2009-04-16
10:57:47.669--UnitOfWork(4641320)--Thread(Thread[main,5,main])--Merge
clone with references eclipselinktest.SimpleEnity[id=1]
[EL Finest]: 2009-04-16
10:57:47.67--UnitOfWork(4641320)--Thread(Thread[main,5,main])--Execute
query ReadObjectQuery(referenceClass=SimpleEntity )
[EL Fine]: 2009-04-16
10:57:47.671--ServerSession(20248218)--Connection(12590745)--Thread(Thread[main,5,main])--SELECT
ID, VALUE, VERSION FROM SIMPLEENTITY WHERE (ID = ?)
bind => [1]
[EL Finer]: 2009-04-16
10:57:47.673--UnitOfWork(4641320)--Thread(Thread[main,5,main])--begin
unit of work commit
[EL Finer]: 2009-04-16
10:57:47.674--ClientSession(25358187)--Connection(15855697)--Thread(Thread[main,5,main])--begin
transaction
[EL Finest]: 2009-04-16
10:57:47.674--UnitOfWork(4641320)--Thread(Thread[main,5,main])--Execute
query InsertObjectQuery(eclipselinktest.SimpleEnity[id=1])
[EL Fine]: 2009-04-16
10:57:47.675--ClientSession(25358187)--Connection(15855697)--Thread(Thread[main,5,main])--INSERT
INTO SIMPLEENTITY (ID, VALUE, VERSION) VALUES (?, ?, ?)
bind => [1, entity, 1]
[EL Finer]: 2009-04-16
10:57:47.676--ClientSession(25358187)--Connection(15855697)--Thread(Thread[main,5,main])--commit
transaction
[EL Finer]: 2009-04-16
10:57:47.677--UnitOfWork(4641320)--Thread(Thread[main,5,main])--end unit
of work commit
[EL Finer]: 2009-04-16
10:57:47.677--UnitOfWork(4641320)--Thread(Thread[main,5,main])--resume
unit of work
[EL Finer]: 2009-04-16
10:57:47.677--UnitOfWork(4641320)--Thread(Thread[main,5,main])--release
unit of work
[EL Finer]: 2009-04-16
10:57:47.677--ClientSession(25358187)--Thread(Thread[main,5,main])--client
released
BUILD SUCCESSFUL (total time: 2 seconds)
James Sutherland schrieb:
A lock error should occur on your merge() call, it is unexpected if it does
not.
Ensure that you have an @Version in your object. If still not getting the
error please include the code for your class and the log on finest of your
test.
Mathias Koehnke - Sun Microsystems wrote:
Hi,
while replacing Toplink Essentials (2.0.1-b04-fcs (04/11/2008)) by
EclipseLink 1.1 for a Java SE project, I came across a problem that
prevents me from switching: I would expect getting an Optimistic Lock
exception in case an entity gets removed from the database (by another
thread or whatever) and one tries to commit on a still-existing runtime
object of that entity. That was my expectation and it worked with
Toplink Essentials so far. Using EclipseLink it doesn't throw an OL
exception, instead the entity gets re-inserted in the database.
Am I using JPA/EclipseLink the wrong way or do I miss something? From my
understanding the following example should throw an OL exception when
committing the last transaction:
Entity entity = new Entity();
entity.setValue("entity");
//persist "entity" and create clone "entityCopy"
EntityManager em1 = getEntityManagerFactory().createEntityManager();
em1.getTransaction().begin();
em1.persist(entity);
em1.getTransaction().commit();
Entity entityCopy = em1.find(Entity.class, entity.getId());
em1.close();
//delete "entity" from database
EntityManager em2 = getEntityManagerFactory().createEntityManager();
em2.getTransaction().begin();
entity = em2.merge(entity);
em2.remove(entity);
em2.getTransaction().commit();
em2.close();
//merge clone "entityCopy" and commit
EntityManager em3 = getEntityManagerFactory().createEntityManager();
em3.getTransaction().begin();
entityCopy = em3.merge(entityCopy);
em3.lock(entityCopy, LockModeType.WRITE);
em3.getTransaction().commit();
em3.close();
Note: I already added a SessionCustomizer modifying the session the
following way:
session.getProject().assumeExistenceForDoesExist();
So, EclipseLink shouldn't check the database for the existence of the
entity at all. Instead it should assume that the entity exists and
simply execute an "UPDATE ..." sql statement.
Thanks for your help in advance.
Best regards,
Mathias Koehnke
-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink , http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki: http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book: http://en.wikibooks.org/wiki/Java_Persistence Java Persistence