当我在mysql提示符下运行命令时,它可以正常工作。
SELECT d.lastUpdatedDate,c.phoneNumber1,d.simImea1, d.simImea2,d.model,c.latitude, c.longitude from connectionDetails c inner join deviceDetails d on (c.deviceUniqueIdentity = d.deviceUniqueIdentity AND d.rowStatus='0')
异常
Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: connectionDetails is not mapped [SELECT d.lastUpdatedDate,c.phoneNumber1,d.simImea1, d.simImea2,d.model,c.latitude, c.longitude from connectionDetails c inner join deviceDetails d on (c.deviceUniqueIdentity = d.deviceUniqueIdentity AND d.rowStatus='0')]
at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:96)
at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120)
ConnectionDetails.hbm
<hibernate-mapping>
<class name="com.mypackage.CConnectionDetails"
table="connectionDetails">
<id name="connectionUniqueIdentity" type="java.lang.String">
<column name="connectionUniqueIdentity" />
<generator class="assigned" />
编辑:
Query query = currentSession().createSQLQuery(sql);
答案 0 :(得分:0)
我从
更改了我的代码Query query = currentSession().createSQLQuery(sql);
要
Query query = currentSession().createQuery(sql);
它有效。