Bugs item #842237, was opened at 2003-11-14 18:59
Message generated for change (Settings changed) made by loubyansky
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=842237&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
>Resolution: Accepted
Priority: 5
Submitted By: Arnold Hahamyan (ahahamyan)
>Assigned to: Alexey Loubyansky (loubyansky)
Summary: Optimistic Locking Problem with JBoss 3.2.2

Initial Comment:
I am trying to use the version-column strategy for 
optimistic locking. I have a table on mysql which has a 
version column (bigint). I have cmp getter and setters 
for this column on my entity bean just like other fields. 
In order to check to see if the client has stale data 
when updating I am checking version number of the DTO 
(value object) against the bean's version number in a 
modify method on the bean class. I am using the 
Instance per Transaction 2.x entity bean configuration 
and extending it by overriding the lock-policy NoLock 
with OptimisticLock as show in the documentation. I also 
have the following specified in the jbosscmp-jdbc.xml for 
the entity bean. 

<optimistic-locking>
<version-column/>
<field-name>version</field-name>
<column-name>version</column-name>
</optimistic-locking>

When I am creating a new entity bean through 
ejbcreate, I get the following error which leads me to 
believe that I cannot have cmp getters/setters on the 
version field, but I need to be able to check for stale 
data the client might have had during the "think-time"

jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.Us
er] Executing SQL: INSERT INTO usr(username, 
password, ftp_username, ftp_password, admin_rights, 
alter_media, alter_segments, alter_schedules, 
alter_players, version, version) VALUES 
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#userName] Set parameter: index=1, 
jdbcType=VARCHAR, value=arnold
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#password] Set parameter: index=2, 
jdbcType=VARCHAR, value=secret
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#ftpUserName] Set parameter: index=3, 
jdbcType=VARCHAR, value=firesign-ftp-usr
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#ftpPassword] Set parameter: index=4, 
jdbcType=VARCHAR, value=firesign-ftp-pass
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#adminRights] Set parameter: index=5, 
jdbcType=VARCHAR, value=yes
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#alterMedia] Set parameter: index=6, 
jdbcType=VARCHAR, value=yes
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#alterSegments] Set parameter: index=7, 
jdbcType=VARCHAR, value=no
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#alterSchedules] Set parameter: index=8, 
jdbcType=VARCHAR, value=no
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#alterPlayers] Set parameter: index=9, 
jdbcType=VARCHAR, value=yes
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBrid
ge.User#version] Set parameter: index=10, 
jdbcType=BIGINT, value=NULL
2003-11-13 21:59:41,224 TRACE 
[org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCLongVersionFi
eldBridge.User#version] Set parameter: index=11, 
jdbcType=BIGINT, value=1
2003-11-13 21:59:41,264 ERROR 
[org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityComman
d.User] Could not create entity
java.sql.SQLException: General error, message from 
server: "Column 'version' specified twice"
The optimistic locking feature works fine as long as I do 
not use the same field with CMP getter and setters, but 
then how to I make sure that the client is not working 
with stale data. The test was performed on Windows XP 
PRO using JDK 1.4.2, JBoss 3.2.2, and MySQL 4.0.16


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

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


-------------------------------------------------------
This SF. Net email is sponsored by: GoToMyPC
GoToMyPC is the fast, easy and secure way to access your computer from
any Web browser or wireless device. Click here to Try it Free!
https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to