[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - auto-increment trouble
smougenot
do-not-reply at jboss.com
Fri Oct 26 13:19:10 EDT 2007
I'm using JBoss 3.2.3 and Sybase ASE 12.5.4.
(can't change those versions)
I'm not hable to have my generated field (not a key) read after insert/update using <auto-increment/> in jbosscmp-jdbc.xml.
The database schema contains a "version like" column for each table.
This column is auto generated by the database (in Sybase it is known as a timestamp even if it a varbinary data) this field is a Java byte[] (returned by the driver) mapped in a Object bean property.
The value is changed every time the line is modified (done by the database).
My trouble was this value wasn't read after the insert (or update). I found the interesting <auto-increment/> for the configuration then tried to use it.
jbosscmp-jdbc.xml (the column here is Mvs_timestamp)
| <?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
|
| <jbosscmp-jdbc>
| <defaults>
| <datasource>java:/jdbc/XXXPooled</datasource>
| <datasource-mapping>Sybase</datasource-mapping>
| </defaults>
| <enterprise-beans>
| <entity>
| <ejb-name>LO_MVT_STOCK</ejb-name>
| <create-table>false</create-table>
| <remove-table>false</remove-table>
| <table-name>LO_MVT_STOCK</table-name>
| <cmp-field>
| <field-name>Mvs_clef</field-name>
| <column-name>MVS_CLEF</column-name>
| </cmp-field>
| <cmp-field>
| <field-name>Mvs_user</field-name>
| <column-name>MVS_USER</column-name>
| </cmp-field>
| <cmp-field>
| <field-name>Mvs_qte</field-name>
| <column-name>MVS_QTE</column-name>
| </cmp-field>
| <cmp-field>
| <field-name>Mvs_motif</field-name>
| <column-name>MVS_MOTIF</column-name>
| </cmp-field>
| ...
| <cmp-field>
| <field-name>Mvs_date_crea</field-name>
| <column-name>MVS_DATE_CREA</column-name>
| </cmp-field>
| <cmp-field>
| <field-name>Mvs_date_sup</field-name>
| <column-name>MVS_DATE_SUP</column-name>
| </cmp-field>
| <cmp-field>
| <field-name>Mvs_timestamp</field-name>
| <column-name>MVS_TIMESTAMP</column-name>
| <auto-increment/>
| </cmp-field>
| </entity>
| </enterprise-beans>
| <dependent-value-classes>
| </dependent-value-classes>
| </jbosscmp-jdbc>
|
When I run a simple unit test that creates a new line the generated column is not read.
Here is the SQL statements :
| 18:10:02,024|16|5|statement|SELECT COUNT(*) FROM LO_MVT_STOCK WHERE MVS_CLEF=?
| 18:10:02,071|32|5|statement|INSERT INTO LO_MVT_STOCK (MVS_CLEF, MVS_USER, MVS_QTE, MVS_MOTIF, ... , MVS_DATE_CREA, MVS_DATE_SUP, MVS_TIMESTAMP) VALUES (?, ... ?)
| 18:10:02,102|0|5|commit||
|
Please could someone tell me what to do?
Is it impossible ? (I hope not)
If it's not possible what could you suggest me to do?
Thank you for your attention
Sylvain
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4099445#4099445
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4099445
More information about the jboss-user
mailing list