Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-dev] JPA query - NOT MEMBER OF exception

I have a very simple test case involving a single Java class, two database tables, a basic collection mapping and JPA queries.  The SQL for the DB schema is shown below

 

CREATE TABLE Z_INSTANCES (

  INSTANCE_UUID CHAR(36) NOT NULL

, NAME VARCHAR2(256)

, CONSTRAINT Z_INSTANCES_PK PRIMARY KEY (INSTANCE_UUID) using index tablespace &INDEX_TABLESPACE ENABLE) tablespace &DATA_TABLESPACE;

 

CREATE TABLE Z_GROUPS(

  INSTANCE_UUID CHAR(36) NOT NULL

, GROUP_UUID CHAR(36) NOT NULL

, CONSTRAINT GROUPS_UK1 U! ! ! NIQUE (INSTANCE_UUID,GROUP_UUID) using index tablespace &INDEX_TABLESPACE ENABLE

, CONSTRAINT Z_INSTANCES_FK1 FOREIGN KEY (INSTANCE_UUID)

    REFERENCES Z_INSTANCES(INSTANCE_UUID) ON DELETE CASCADE ENABLE) tablespace &DATA_TABLESPACE;

 

The Java class is very simple

 

public class Zinstance {

    private String uuid;

    private String name;

    private Set<String> groupUUIDs;

    public Zinstance() {

        this.uuid = UUID.randomUUID().toString();

        this.groupUUIDs = new HashSet<String>();

    }

}

 

The OR mapping is shown below:

 

                <entity class="my.temp.Zinstance">

                                <table name="Z_INSTANCES" />

                                <attributes>

                                                <id name="uuid">

                                                                <co! ! ! lumn name="INSTANCE_UUID" updatable="false" />

                                                </id>

                                                <basic name="name">

                                                                <column name="NAME" />

                                                </basic>

                                                <basic-collection name="groupUUIDs">

                                                                <value-column name="GROUP_UUID" />

                                                                <collection-table name="Z_GROUPS">

                                                                                <primary-key-join-column>INSTANCE_UUID</primary-key-join-column>

                                                                </collection-table>

                                                                <private-owned />

                                                                <join-fetch>OUTER</join-fetch>

                                                </basic-collection>

                                </attributes>

                </entity>

 

 

I attempted the following JPA queries

 

SELECT a FROM Zinstance a                                     <-Success

SELECT a FROM Zinstance a WHERE a.groupUUIDs = ?1           ! ;! ;! ;  <-Success

SELECT a FROM Zinstance a WHERE ?1 LIKE a.groupUUIDs          <-Success

SELECT a FROM Zinstance a WHERE ?1 NOT LIKE a.groupUUIDs      <-Fail incorrect results

SELECT a FROM Zinstance a WHERE a.groupUUIDs IS EMPTY         <-Success

SELECT a FROM Zinstance a WHERE a.groupUUIDs IS NOT EMPTY     <-Success

SELECT a FROM Zinstance a WHERE ?1 MEMBER OF a.groupUUIDs     <-Success

SELECT a FROM Zinstance a WHERE ?1 NOT MEMBER OF a.groupUUIDs <-Fail CCE

 

The ClassCastException for the “NOT MEMBER OF” should I file a bug or is it user error?  Is there an alternative syntax for this type of query?

FYI I am using EclipseLink 2.3.1.

 

Exception [EclipseLink-6168] (Eclipse Persistence Services - 2.3.1.v20111018-r10243): org.eclipse.persistence.exceptions.QueryException

Exception Description: Query failed to prepare, unexpected error occurred: [java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.persistence.internal.descriptors.PersistenceObject].

Internal Exception: java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.persistence.internal.descriptors.PersistenceObject

Query: ReadAllQuery(referenceClass=Zinstance jpql="SELECT a FROM Zinstance a WHERE 'b54f6d66-07fe-4d04-97f6-acff6722236a' NOT MEMBER OF a.groupUUIDs")

       at org.eclipse.persistence.exceptions.QueryException.prepareFailed(QueryException.java:1555)

       at org.eclipse.persistence.queries.DatabaseQuery.checkPrepare(DatabaseQuery.java:625)

       at org.eclipse.persistence.queries.ObjectLevelReadQuery.checkPrepare(ObjectLevelReadQuery.java:823)

       at org.eclipse.persistence.queries.DatabaseQuery.prepareCall(DatabaseQuery.java:1741)

       at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:268)

       at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:190)

       at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:142)

       at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>(EJBQueryImpl.java:126)

       at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1475)

       at oracle.oer.orc.persistence.temp.BasicCollectionIntegTest.query(BasicCollectionIntegTest.java:131)

 

 

 


Back to the top