EclipseLink - Invalid request key [lastVersionFlag] in expression

I just upgraded from Toplink to EclipseLink and ran this error

Exception [EclipseLink-6015] (Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3): org.eclipse.persistence.exceptions.QueryException Exception Description: Invalid request key [lastVersionFlag] in the expression. Query: ReadAllQuery (name = "bookingVersionCollection" referenceclass = BookingVersion)

My handle 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 the BookingVersion class that has a mapping for this field

 DirectToFieldMapping latestVersionFlagMapping = new DirectToFieldMapping(); latestVersionFlagMapping.setAttributeName("latestVersionFlag"); latestVersionFlagMapping.setFieldName("RS_BOOKINGVERSION.LATESTVERSIONFLAG"); descriptor.addMapping(latestVersionFlagMapping); 

And inside the Java poco object of the BookingVersion.java object, this field looks like this.

 private char latestVersionFlag = ResConstants.FLAG_YES; 

Any ideas? This code worked in Toplink, so I'm not sure what is going on.

+5
source share
1 answer

Well, 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 send it to someone else!

+1
source

Source: https://habr.com/ru/post/1236380/


All Articles