Hello, I'm facing a strange problem with the @Version Annotation with field property as Timestamp. With a bulk update I'll get the following error: javax.ejb.EJBException: The bean encountered a non-application exception; nSign outested exception is: <openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: java.util.Date incompatible with java.lang.String If I change the @Version field property from a Timestamp to an int it works fine.
I'm using OpenJPA 1.2.1, OpenEJB 3.1.4 and HSQL 1.8.1 (I have the same problem when I use DB2.). I build my project with Maven and I enhance the classes with the maven plugin. I could try to provide a simple testcase if one is needed. I have created a simple project (starting from openejb sample) with the following classes: I have a sample JPA entity "Movie" wit the following attribute: @Id private int id; private String director; private String title; private int year; @Version private Timestamp lastUpdate; My unit test insert the following 4 objects in the DB: id: 1,director=Quentin Tarantino,title:Reservoir Dogs,year:1992 id: 2,director=Quentin Tarantino,title:Kill Bill,year:2001 id: 3,director=Joel Coen,title:Fargo,year:1996 id: 4,director=Joel Coen,title:The Big Lebowski,year:1998 When I call from my unit the stateless session bean method: public int singleUpdate(String director) { String s = "select m from Movie as m where m.director='"+director+"'"; Query q = entityManager.createQuery(s); List<Movie> list = q.getResultList(); for (Iterator<Movie> iter = list.iterator(); iter.hasNext();) { Movie movie = iter.next(); movie.setDirector("myTestsingleUpdate"); entityManager.merge(movie); } return list.size(); } It successfully updates two records associated to the director=Joel Coen. When I call from my unit test the stateless session bean method: public int bulkUpdate(String director) { String s = "update Movie m set m.director = 'bulkUpdate' where m.director='"+director+"'"; Query q = entityManager.createQuery(s); return q.executeUpdate(); } It should update two records but I'll get the following error: est(org.superbiz.injection.jpa.MoviesTest) Time elapsed: 0.844 sec <<< ERROR! javax.ejb.EJBException: The bean encountered a non-application exception; nested exception is: <openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: java.util.Date incompatible with java.lang.String at org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:359) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:287) at $Proxy31.bulkUpdate(Unknown Source) at org.superbiz.injection.jpa.MoviesTest.test(MoviesTest.java:80) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at junit.framework.TestResult$1.protect(TestResult.java:110) at junit.framework.TestResult.runProtected(TestResult.java:128) at junit.framework.TestResult.run(TestResult.java:113) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:228) at junit.framework.TestSuite.run(TestSuite.java:223) at org.junit.internal.runners.OldTestClassRunner.run(OldTestClassRunner.java:35) at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:35) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:146) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:97) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103) at $Proxy0.invoke(Unknown Source) at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145) at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69) Caused by: <openjpa-1.2.1-r752877:753278 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: java.util.Date incompatible with java.lang.String at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:814) at org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:884) at org.apache.openjpa.kernel.QueryImpl.updateAll(QueryImpl.java:880) at org.apache.openjpa.kernel.DelegatingQuery.updateAll(DelegatingQuery.java:565) at org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:339) at org.superbiz.injection.jpa.MoviesImpl.bulkUpdate(MoviesImpl.java:53) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:162) at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:144) at org.apache.openejb.monitoring.StatsInterceptor.record(StatsInterceptor.java:164) at org.apache.openejb.monitoring.StatsInterceptor.invoke(StatsInterceptor.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at org.apache.openejb.core.interceptor.ReflectionInvocationContext$Invocation.invoke(ReflectionInvocationContext.java:162) at org.apache.openejb.core.interceptor.ReflectionInvocationContext.proceed(ReflectionInvocationContext.java:144) at org.apache.openejb.core.interceptor.InterceptorStack.invoke(InterceptorStack.java:122) at org.apache.openejb.core.stateless.StatelessContainer._invoke(StatelessContainer.java:221) at org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:174) at org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:217) at org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:77) at org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:282) ... 27 more Caused by: java.lang.ClassCastException: java.util.Date incompatible with java.lang.String at org.apache.openjpa.jdbc.sql.DBDictionary.appendUpdates(DBDictionary.java:2085) at org.apache.openjpa.jdbc.sql.DBDictionary.toBulkOperation(DBDictionary.java:1930) at org.apache.openjpa.jdbc.sql.DBDictionary.toUpdate(DBDictionary.java:1882) at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeBulkOperation(JDBCStoreQuery.java:495) at org.apache.openjpa.jdbc.kernel.JDBCStoreQuery.executeUpdate(JDBCStoreQuery.java:440) at org.apache.openjpa.kernel.ExpressionStoreQuery$DataStoreExecutor.executeUpdate(ExpressionStoreQuery.java:694) at org.apache.openjpa.kernel.QueryImpl.update(QueryImpl.java:1039) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:809) ... 52 more As I already written, when I change the @Version field property from a Timestamp to an int it works fine. Any clue? Thanks in advance