eclipselink 2.4 mongodb with criteria api [message #876616] |
Fri, 25 May 2012 00:34 |
Bob Treacy Messages: 1 Registered: May 2012 |
Junior Member |
|
|
I am using a nightly build (5-24-2012) of eclipselink-plugins-2 and eclipselink-plugins-nosql-2 to connect to mongodb using JPA Criteria API
I'm getting a ClassCastException when I try to query membership in an element collection
org.eclipse.persistence.internal.jpa.metamodel.SingularAttributeImpl cannot be cast to javax.persistence.metamodel.PluralAttribute
java.lang.ClassCastException: org.eclipse.persistence.internal.jpa.metamodel.SingularAttributeImpl cannot be cast to javax.persistence.metamodel.PluralAttribute
at org.eclipse.persistence.internal.jpa.querydef.FromImpl.get(FromImpl.java:315)
at edu.harvard.iq.text.preprocess.MongoPairwiseAgreement.get(MongoPairwiseAgreement.java:42)
at edu.harvard.iq.text.preprocess.MongoPairwiseAgreementTest.testGet(MongoPairwiseAgreementTest.java:57)
@Override
public Boolean get(String setId,DocPair docPair, Integer methodId) {
...
CriteriaBuilder qb = em.getCriteriaBuilder();
CriteriaQuery<PairwiseMethods> c = qb.createQuery(PairwiseMethods.class);
Root<PairwiseMethods> p = c.from(PairwiseMethods.class);
// the following line is line 42 of MongoPairWiseAgreement that creates the issue:
c.select(p).where(qb.isMember(methodId, p.<List<Integer>>get("methodIds")));
TypedQuery<PairwiseMethods> query = em.createQuery(c);
...
this is line 315 of org.eclipse.persistence.internal.jpa.querydef.FromImpl.java:
if (!((PluralAttribute) attribute).getElementType().getPersistenceType().equals(PersistenceType.BASIC)) {
// Here are the essentials of my PairwiseMethods class:
@Entity
@NoSql(dataFormat=DataFormatType.MAPPED)
public class PairwiseMethods implements Serializable {
@Id
@GeneratedValue
@Field(name = "_id")
protected String id;
protected String setId;
protected DocPair docPair;
@ElementCollection
protected List<Integer> methodIds;
This is what the data looks like in mongodb:
> db.PAIRWISEMETHODS.find()
{ "_id" : "4FBEA15C1A886598E77A44FE", "METHODIDS" : [ 1, 2 ], "SETID" : "testSet", "DOCPAIR" : [ { "DOC1ID" : "doc1", "DOC2ID" : "doc2" } ] }
[Updated on: Fri, 25 May 2012 12:52] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03209 seconds