例外,表未映射

时间:2014-11-13 11:04:11

标签: java mysql hibernate

当我在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);

1 个答案:

答案 0 :(得分:0)

我从

更改了我的代码
Query query = currentSession().createSQLQuery(sql);

Query query = currentSession().createQuery(sql);

它有效。