I just upgraded from Toplink to EclipseLink and am running in to this error
Exception [EclipseLink-6015] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.QueryException Exception Description: Invalid query key [latestVersionFlag] in expression. Query: ReadAllQuery(name="bookingVersionCollection" referenceClass=BookingVersion )
My descriptor looks like this
OneToManyMapping bookingVersionCollectionMapping = new OneToManyMapping();
bookingVersionCollectionMapping.setAttributeName("bookingVersionCollection");
bookingVersionCollectionMapping.setReferenceClass(BookingVersion.class);
bookingVersionCollectionMapping.useTransparentCollection();
bookingVersionCollectionMapping.useCollectionClass(IndirectList.class);
bookingVersionCollectionMapping.addAscendingOrdering("bookingVersionID");
bookingVersionCollectionMapping.addTargetForeignKeyFieldName("RS_BOOKINGVERSION.RS_BKG_ID", "RS_BOOKING.RS_BKG_ID");
bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
.and(expBuilder.get("latestVersionFlag").equal(ResConstants.FLAG_YES)));
descriptor.addMapping(bookingVersionCollectionMapping);
I also have a mapping for BookingVersion class that has the mapping for that field
DirectToFieldMapping latestVersionFlagMapping = new DirectToFieldMapping();
latestVersionFlagMapping.setAttributeName("latestVersionFlag");
latestVersionFlagMapping.setFieldName("RS_BOOKINGVERSION.LATESTVERSIONFLAG");
descriptor.addMapping(latestVersionFlagMapping);
And inside the Java poco object of BookingVersion.java that field looks like this..
private char latestVersionFlag = ResConstants.FLAG_YES;
Any ideas? This code worked in Toplink, so not sure what's going on.
Well, by changing
bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
.and(expBuilder.get("latestVersionFlag").equal(ResConstants.FLAG_YES)));
to
bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
.and(expBuilder.getField("RS_BOOKINGVERSION.LATESTVERSIONFLAG").equal(ResConstants.FLAG_YES)));
seems to work..... still not sure why, but thought I would post for anyone else!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With