openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chintan4181 <chintan4...@gmail.com>
Subject @Version for sqlserver "timpstamp" datatype
Date Wed, 13 Apr 2011 00:20:19 GMT
Hi,

In my sql server 2005 database schema, all tables have one column with
"timestamp" dataType. When I generate entity out of it, Java maps that
column with java.sql.TimeStamp dataType. but when I retrieve entity using
JPA, i am getting below error. 

2 PDT] 00000044 SystemErr     R Caused by:
com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from
timestamp to TIMESTAMP is unsupported.
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:171)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:1117)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:2419)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:176)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:113)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1981)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:1966)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.microsoft.sqlserver.jdbc.SQLServerResultSet.getTimestamp(SQLServerResultSet.java:2367)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getTimestamp(WSJdbcResultSet.java:2613)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.lib.jdbc.DelegatingResultSet.getTimestamp(DelegatingResultSet.java:189)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.sql.DBDictionary.getTimestamp(DBDictionary.java:871)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.sql.ResultSetResult.getTimestampInternal(ResultSetResult.java:485)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.sql.ResultSetResult.getObjectInternal(ResultSetResult.java:439)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.sql.AbstractResult.getObject(AbstractResult.java:691)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy.populateFromResult(ColumnVersionStrategy.java:336)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.meta.strats.ColumnVersionStrategy.load(ColumnVersionStrategy.java:269)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.meta.Version.load(Version.java:343)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1103)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.load(JDBCStoreManager.java:1076)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initializeState(JDBCStoreManager.java:447)
[4/12/11 16:16:59:642 PDT] 00000044 SystemErr     R 	at
org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:342) 

I am using Microsoft SQL Server JDBC Driver 3.0. and driver documentation
says that  
Note:  
The SQL Server timestamp type is a fixed-length binary-string type. It does
not map to any of the JDBC time types: DATE, TIME, or TIMESTAMP. 

And I want to make "timestamp" column as a @version column to implement
Optimistic locking. since it is existing database i can not add new column
with int dataType for versioning. 

Is there a way to use sql server "timestamp" type as @version column in
JPA/OpenJPA?

Thanks
Chintan




--
View this message in context: http://openjpa.208410.n2.nabble.com/Version-for-sqlserver-timpstamp-datatype-tp6267241p6267241.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Mime
View raw message