Bugs item #1006723, was opened at 2004-08-10 09:56
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1006723&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Ivan Parra (ioparra)
Assigned to: Nobody/Anonymous (nobody)
Summary: Optimistic CMP/CMR with version-column + on-load

Initial Comment:
Win2K
JDK1.3.1_06
JBoss3.2.5
Container configurations
(on-load, cached, invalidation, optimistic)

Steps to reproduce the bug:
I haven't tested this exact setup, to my knowledge, this 
give the same results.

Table A{ pk, oca }
Table B{ pk, a_pk, oca}

For both tables, OCA is used for optimistic locking
(verrsion-column) and is initialized to a number(either by 
initial insert or create via ejb).

Relation from A->B is one to many. The initial 
environment is like so.

A1->B1
A2->B2 

When we run this pseudo code:

B1 = findByPrimaryKey(b1_pk)
A2 = findByPrimaryKey(a2_pk)
ArrayList list  =  new ArrayList();
list.add(b1);
A2.setBs(list);  

The new state should be:
A2->B1
A1  (no relation)  
B1  (no relation)

When we run this code with on-find, it runs fine.  With 
on-load, it fails with this exception snippet:

INFO  [STDOUT]  + nested throwable:
 INFO  [STDOUT] javax.ejb.EJBException: Update failed. 
Expected one affected row: rowsAffected=0, id=42
 INFO  [STDOUT]     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand.
execute(JDBCStoreEntityCommand.java:155)
 INFO  [STDOUT]     at 
org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.storeEn
tity(JDBCStoreManager.java:635)
 INFO  [STDOUT]     at 
org.jboss.ejb.plugins.CMPPersistenceManager.storeEntity
(CMPPersistenceManager.java:395)
 INFO  [STDOUT]     at 
org.jboss.resource.connectionmanager.CachedConnection
Interceptor.storeEntity
(CachedConnectionInterceptor.java:387)


I turned on DEBUG/TRACE to see what the query was 
and found these 2 queries.  Notice how the first query is 
created incorrectly and mid-setup, the second query is 
ran.  Also notice that the failure occurred not on the 
assignment of the new relation, but the disassociations 
of the old(ie... B2 removing itself from A2)

1) DEBUG 
[org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreEntityCommand
.AppConfig] Executing SQL: UPDATE B SET A_PK=?, 
OCA=? WHERE PK=? AND OCA IS NULL
 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.B#pk] Set parameter: index=1, jdbcType=BIGINT, 
value=NULL

2) DEBUG 
[org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.
AppConfig] Executing SQL: SELECT OCA FROM B WHERE 
(PK=?)
 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.B#pk] Set parameter: index=1, jdbcType=BIGINT, 
value=42

 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCLongVersionFi
eldBridge.B#version_lock] Set parameter: index=2, 
jdbcType=INTEGER, value=4
 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.B#id] Set parameter: index=3, jdbcType=BIGINT, 
value=42

Because of the ordering, the first SQL has ORA is NULL.  
Then the ora is selected(but is to late).

---
When I run this exact same code with on-find, it runs 
just fine.  I can only suspect it works because B2's OCA 
is pre-loaded.

Let me know if you need more information or exact test-
case.

-Ivan

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=1006723&group_id=22866


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to