Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » JPA query - NOT MEMBER OF exception(Basic collection mapping CCE using NOT MEMBER OF operator)
JPA query - NOT MEMBER OF exception [message #757341] Thu, 17 November 2011 20:19
Dennis Fuglsang is currently offline Dennis FuglsangFriend
Messages: 1
Registered: November 2011
Junior Member
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 UNIQUE (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">
<column 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

I am using EclipseLink 2.3.1. Is the ClassCastException for the NOT MEMBER OF a bug? Is there an alternative syntax for this type of query?

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)

Previous Topic:Must static-weaving be set in the persistence.xml file if static weaving has been performed
Next Topic:Mapping Compound PK with FK Reference?
Goto Forum:
  


Current Time: Tue Apr 16 19:48:39 GMT 2024

Powered by FUDForum. Page generated in 0.08099 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top