nested exception is org.hibernate.MappingException: Unknown entity,问题解决
2013-06-05 16:35
543 查看
今天遇到了nested exception is org.hibernate.MappingException: Unknown entity的问题,在网上查了方法好多,都和我的不一样。
问题描述如下:
1、我用spring+hibernate,程序在本机myeclipse访问本地mysql没有问题。
2、我在本机把数据库连接改为informix的可以访问,也可以写库。
3、我把代码部署到linux服务器上,访问informix数据库,出现nested exception is org.hibernate.MappingException: Unknown entity这个错误。
解决:
原来我的pojo访问配置为
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="packagesToScan">
<list>
<value>com.xx.xx.pojo</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
</props>
</property>
<property name="entityInterceptor">
<ref local="trimInterceptor" />
</property>
</bean>
改为:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>com.xx.xx.pojo.Address</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
</props>
</property>
<property name="entityInterceptor">
<ref local="trimInterceptor" />
</property>
</bean>
对红色部分进行了替换,如果有多个pojo类,就可以在list下面添加多个value标签~
问题描述如下:
1、我用spring+hibernate,程序在本机myeclipse访问本地mysql没有问题。
2、我在本机把数据库连接改为informix的可以访问,也可以写库。
3、我把代码部署到linux服务器上,访问informix数据库,出现nested exception is org.hibernate.MappingException: Unknown entity这个错误。
解决:
原来我的pojo访问配置为
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="packagesToScan">
<list>
<value>com.xx.xx.pojo</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
</props>
</property>
<property name="entityInterceptor">
<ref local="trimInterceptor" />
</property>
</bean>
改为:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="annotatedClasses">
<list>
<value>com.xx.xx.pojo.Address</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
</props>
</property>
<property name="entityInterceptor">
<ref local="trimInterceptor" />
</property>
</bean>
对红色部分进行了替换,如果有多个pojo类,就可以在list下面添加多个value标签~
相关文章推荐
- org.hibernate.MappingException Unknown entity com.po.Dept问题的解决
- 使用Hibernate出现nested exception is org.hibernate.MappingException: entity class not found:问题
- 用maven管理Spring项目出现org.hibernate.MappingException Unknown entity的问题解决办法
- 2.Unknown entity: java.util.ArrayList; nested exception is org.hibernate.MappingException: Unknown e
- nested exception is org.hibernate.MappingException: entity class not found: com.model.TLiuyan
- org.hibernate.MappingException: Unknown entity常见问题。回顾笔记,以前没记,现在补上,xiaochao写的蛮好的直接给转载了。
- nested exception is org.hibernate.MappingException: entity class not found: com.model.TLiuyan
- org.hibernate.MappingException: Unknown entity解决
- 在版本问题上解决 org.hibernate.MappingException: Unknown entit xxx
- org.hibernate.MappingException: Unknown entity 解决方法
- org.hibernate.MappingException: Unknown entity: org.whatisjava.domain.Order
- org.hibernate.MappingException: Unknown entity 解决方法
- org.hibernate.MappingException: Unknown entity: com.yyw.bean.Post几种可能
- org.hibernate.MappingException:Unknown entity:java.util.ArrayList
- Atitit.解决org.hibernate.DuplicateMappingException: Duplicate class/entity mapping
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -9【问题发现与解决】
- HibernateTemplate删除方式 org.hibernate.MappingException: Unknown entity: java.lang.Long
- 二.could not insert: [xxx.entity.User]; nested exception is org.hibernate.exception.
- Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/annotations/Entity
- org.hibernate.MappingException: Unknown entity