小编Nic*_*yne的帖子

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

我刚刚从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中有效,因此不确定发生了什么.

java eclipselink

5
推荐指数
1
解决办法
845
查看次数

增强此LINQ查询的可读性和性能?

我不是LINQ的最佳人选,但我正在尝试检索当年的所有ModuleAvailabilities地方academicYear.

这里有什么改进吗?

pathway.PathwayFoundationModule.Attach(
    pathway.PathwayFoundationModule.CreateSourceQuery()
        .Include("Module")
        .Include("Module.ModuleAvailabilities.Location")
        .Where(o => o.Module.ModuleAvailabilities
                     .Where(x => x.AcademicYear == academicYear.Current)
                     .Count() >= 0)
);
Run Code Online (Sandbox Code Playgroud)

linq linq-to-objects linq-to-entities

2
推荐指数
1
解决办法
128
查看次数