为什么我的实体类需要在persistence.xml中的<class>注册才好用

我的项目是WAR格式的,所有技术其实也就是JSF,RICHFACE4,WELD,JPA3,实现者是HIBERNATE

不知道为什么我手动创建的实体类保存的时候需要在persistence.xml中的<class></class>把这个类注册在这里,否则就报错,不知道哪位大虾知道啊???求解答!!!。。

我的persistence配置:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
    <persistence-unit name="swcms" transaction-type="JTA"> 
        <provider>org.hibernate.ejb.HibernatePersistence</provider> 
        <jta-data-source>java:jboss/datasources/swcmsDS</jta-data-source>
        <class>com.cms.main.Test</class>
        <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
        <properties>
            <property name="jboss.entity.manager.factory.jndi.name" value="java:/swcmsDSEntityManagerFactory"/>
            <!-- 数据库方言 -->
            <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/> 
            <!-- 显示SQL -->
            <property name="hibernate.show_sql" value="false"/>
            <property name="hibernate.use_sql_comments" value="true"/>
            <!-- 二级缓存 -->
            <property name="hibernate.cache.infinispan.cachemanager" value="java:jboss/infinispan/hibernate"/>
            <property name="hibernate.cache.region.factory_class" value="org.hibernate.cache.infinispan.JndiInfinispanRegionFactory"/>
            <property name="hibernate.cache.use_query_cache" value="true"/>
            <property name="hibernate.cache.use_second_level_cache" value="true"/>
            <!-- 抓取深度 -->
            <property name="hibernate.max_fetch_depth" value="2"/>
            <!-- 自动升级库 -->
            <property name="hibernate.hbm2ddl.auto" value="update"/>
            <!-- 事务级别 -->
            <property name="hibernate.connection.isolation" value="2"/>    
        </properties>
    </persistence-unit>
</persistence>

<class>com.cms.main.Test</class>就是我注册的实体类。如何才能不这样?

猜你喜欢

转载自htllovelw.iteye.com/blog/1250638