当前位置: 代码迷 >> J2EE >> jpa注解的一个小疑点
  详细解决方案

jpa注解的一个小疑点

热度:17   发布时间:2016-04-22 01:52:18.0
jpa注解的一个小问题

在学习jpa注解
在实体类上报这个错,但是运行起来却没有错
Class "org.lw.jpa.entity.Person" is mapped, but is not included in any persistence unit
这是什么原因呢?是编译器还是什么呢?

------解决方案--------------------
在resources的persistence.xml文件中
类似于;
XML code
<persistence xmlns="http://java.sun.com/xml/ns/persistence"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"    version="1.0">    <persistence-unit name="visitorPU" transaction-type="RESOURCE_LOCAL">        <class>com.cybersoft4u.example.domain.Visitor</class>        <class>com.cybersoft4u.example.domain.Comment</class>        <properties>            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />            <!-- <property name="hibernate.hbm2ddl.auto" value="create-drop"/> -->        </properties>    </persistence-unit></persistence>
  相关解决方案