好吧,我正在尝试执行一个简单的查询,但我总是得到一个“未映射的实体”。请参阅我的问题:
"SELECT c FROM MyOwnClass c WHERE c.filter = :filter ORDER BY c.filter";
但是如果我把类的限定名称“br.com.myproject.MyOwnClass”执行了查询。
这是我的persistence.xml文件:
<persistence-unit transaction-type="RESOURCE_LOCAL" name="myPU">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>java:jboss/datasources/myDS</non-jta-data-source>
<class>br.com.myproject.MyOwnClass</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<!-- Properties for Hibernate -->
<property name="hibernate.hbm2ddl.auto" value="none"/>
<property name="hibernate.connection.characterEncoding" value="UTF-8"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="false"/>
</properties>
</persistence-unit>
答案 0 :(得分:0)
您的实体类是否与查询代码不同?您可能只需要添加导入:
import br.com.myproject.MyOwnClass;