EclipseLink - 表达式中的查询键[latestVersionFlag]无效

Nic*_*yne 5 java eclipselink

我刚刚从Toplink升级到EclipseLink并且正在运行此错误

异常[EclipseLink-6015](Eclipse Persistence Services - 2.6.1.v20150916-55dc7c3):org.eclipse.persistence.exceptions.QueryException异常描述:表达式中的查询键[latestVersionFlag]无效.查询:ReadAllQuery(name ="bookingVersionCollection"referenceClass = BookingVersion)

我的描述符看起来像这样

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);
Run Code Online (Sandbox Code Playgroud)

我还有一个BookingVersion类的映射,它具有该字段的映射

DirectToFieldMapping latestVersionFlagMapping = new DirectToFieldMapping();
latestVersionFlagMapping.setAttributeName("latestVersionFlag");
latestVersionFlagMapping.setFieldName("RS_BOOKINGVERSION.LATESTVERSIONFLAG");
descriptor.addMapping(latestVersionFlagMapping);
Run Code Online (Sandbox Code Playgroud)

在BookingVersion.java的Java poco对象中,该字段看起来像这样..

private char latestVersionFlag = ResConstants.FLAG_YES;
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?此代码在Toplink中有效,因此不确定发生了什么.

Nic*_*yne 1

好吧,通过改变

bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
    .and(expBuilder.get("latestVersionFlag").equal(ResConstants.FLAG_YES)));
Run Code Online (Sandbox Code Playgroud)

bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
      .and(expBuilder.getField("RS_BOOKINGVERSION.LATESTVERSIONFLAG").equal(ResConstants.FLAG_YES)));
Run Code Online (Sandbox Code Playgroud)

似乎有效......仍然不知道为什么,但我想我会为其他人发帖!