Hi.

The entity causing the problem:
===============================

@Entity
public class TypeEntity {
@Id
public ... getId();

@Id
@Version
public ... getVersion();
}

The failing query:
==================

pu for xxxx classes  TRACE  [ejbd 10] openjpa.Query - Executing query:
[SELECT entity FROM TypeEntity entity WHERE ( entity.id = :id ) AND (
entity.version = ( SELECT MAX( sameentity.version ) FROM TypeEntity
sameentity WHERE sameentity.id = :id ))] with parameters: {id=1011}

The exception(s) raised:
========================

javax.ejb.EJBException: The bean encountered a non-application
exception.; nested exception is:
        <openjpa-1.0.2-r420667:627158 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: 0
        at
org.apache.openejb.client.EJBInvocationHandler.convertException(EJBInvocationHandler.java:219)
        at
org.apache.openejb.client.EJBObjectHandler._invoke(EJBObjectHandler.java:157)
        at
org.apache.openejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:117)
        at
org.apache.openejb.client.proxy.Jdk13InvocationHandler.invoke(Jdk13InvocationHandler.java:52)
        at $Proxy0.findEntityById(Unknown Source)
        at
org.brenckmann.java.prj.ejbclient.Client.listTypes(Client.java:123)
        at org.brenckmann.java.prj.ejbclient.Client.main(Client.java:50)
Caused by: <openjpa-1.0.2-r420667:627158 nonfatal user error>
org.apache.openjpa.persistence.ArgumentException: 0
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:851)
        at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:773)
        at
org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:525)
        at
org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:237)
        at
org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:277)
        at
org.brenckmann.java.ejb.core.AbstractEntitiesBean.findEntityById(AbstractEntitiesBean.java:115)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


The workarround:
================
If I remove @Version from getVersion() everything is fine.


The Question:
=============
Bug? Or is it forbidden to use a column tagged @Version in a Query?


Ty in advance,
Dirk


Btw.: I already posted the question on the apache geronimo user list:
http://www.nabble.com/%40Version-and-Query-using-version-column-cause-trouble--to20642421s134.html

Reply via email to