Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带投影的Hibertate准则_Java_Hibernate - Fatal编程技术网

Java 带投影的Hibertate准则

Java 带投影的Hibertate准则,java,hibernate,Java,Hibernate,''m正在尝试应用条件。对带有投影的查询的限制 我的代码是: ProjectionList projections = Projections.projectionList().add(Projections.property("mId").as("mId")); projections.add(Projections.property("mDate").as("mDate")); Criteria criteria = mSession.createCriteria(MailAgrosegu

''m正在尝试应用条件。对带有投影的查询的限制

我的代码是:

ProjectionList projections = Projections.projectionList().add(Projections.property("mId").as("mId"));
projections.add(Projections.property("mDate").as("mDate"));

Criteria criteria = mSession.createCriteria(MailAgroseguro.class)
    .add(Restrictions.between("mDate", dateMin, dateMax))
    .setProjection(projections)
    .setResultTransformer(new AliasToBeanNestedResultTransformer(ObjectClass.class));
listObjectClass = (List<ObjectClass>)criteria.list();
错误是:

Hibernate: select this_.mId as y0_, this_.mDate as y1_ from objectclass this_ where y1_ between ? and ?
[INFO] 2014-11-21 16:59:24,554 - org.hibernate.util.JDBCExceptionReporter -25221 [JavaFX Application Thread] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 1054, SQLState: 42S22
[INFO] 2014-11-21 16:59:24,554 - org.hibernate.util.JDBCExceptionReporter -25221 [JavaFX Application Thread] ERROR org.hibernate.util.JDBCExceptionReporter  - Unknown column 'y1_' in 'where clause'
如果我没有添加限制或投影效果很好

Edited2:更新的错误


谢谢大家

格式有点麻烦,你的大部分代码都被压扁了。第二,你也可以打印你的模型吗?只有字段声明,没有setter/getter。假设您正在使用,您的代码适合我。通过将org.hibernate.SQL类别设置为DEBUG,尝试记录生成的SQL。也许这会给你一个线索。是的,我正在使用那个类。用声明了“mDate”的SQLWhere粘贴了错误&在哪个类中,您可以更新相关代码。抱歉,将MFechaRecepcionin西班牙语更改为mDate。我已将此名称发布
Hibernate: select this_.mId as y0_, this_.mDate as y1_ from objectclass this_ where y1_ between ? and ?
[INFO] 2014-11-21 16:59:24,554 - org.hibernate.util.JDBCExceptionReporter -25221 [JavaFX Application Thread] WARN  org.hibernate.util.JDBCExceptionReporter  - SQL Error: 1054, SQLState: 42S22
[INFO] 2014-11-21 16:59:24,554 - org.hibernate.util.JDBCExceptionReporter -25221 [JavaFX Application Thread] ERROR org.hibernate.util.JDBCExceptionReporter  - Unknown column 'y1_' in 'where clause'