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

时间:2015-11-19 23:21:03

标签: 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);

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

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

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

private char latestVersionFlag = ResConstants.FLAG_YES;

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

1 个答案:

答案 0 :(得分:1)

好吧,改变

bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
    .and(expBuilder.get("latestVersionFlag").equal(ResConstants.FLAG_YES)));

bookingVersionCollectionMapping.setSelectionCriteria(bookingVersionCollectionMapping.buildSelectionCriteria()
      .and(expBuilder.getField("RS_BOOKINGVERSION.LATESTVERSIONFLAG").equal(ResConstants.FLAG_YES)));

似乎工作......仍然不确定原因,但我想我会为其他人发帖!