我遇到了在java中使用hibernate for postgres表执行以下查询的问题。
该查询用于使用内连接从3个表中检索数据。
查询:
QryJourney = "SELECT journey.id,journey.operatingday,journey.linename,journey.scheduledeparture,journey.scheduledeparturestopname,journeydetail.stopname,journeydetail.latitude,journeydetail.longitude从旅程左加入journey_journeydetail ON journey.id = journey_journeydetail.journey_id左加入journey_journeydetail.journeydetails_id = journeydetail.id WHERE journey.id = '155815228‘ORDER BY journeydetail.schedulearrival";
一旦执行,就发生了以下异常。
例外:
线程"main“中出现异常org.hibernate.hql.internal.ast.QuerySyntaxException:意外标记:在第1行附近的第268列,选择journey.id,journey.operatingday,journey.linename,journey.scheduledeparture,journey.scheduledeparturestopname,journeydetail.stopname,journeydetail.latitude,journeydetail.longitude FROM de.db.journeyTracker.model.journey left JOIN journey_journeydetail ON journey.id = journey_journeydetail.journey_id left join journey_journeydetail ON journey_journeydetail.journeydetails_id = journeydetail.id WHERE journey.id = '155815228‘ORDER BY journeydetail.schedulearrival
Tis查询在postgres上运行100%,同时在其SQL窗格上执行。有谁知道吗?
向Usman致敬
发布于 2012-07-21 21:59:49
Hibernate查询是用Hibernate Query Language (HQL)编写的,而不是原生SQL。在HQL语言中重新表述您的查询,或者使用native query在Hibernate中使用SQL。
Hibernate是一个对象关系映射器。它不只是给你一个结果集。如果需要,可以使用PgJDBC直接使用JDBC。
如果希望本机域对象作为查询结果,请结合使用Hibernate和HQL,或者通过本地查询映射使用Hibernate。原生查询比较麻烦,因为您必须显式地告诉Hibernate所有结果列如何映射到您的结果对象。
https://stackoverflow.com/questions/11580003
复制相似问题