hibernate model mapping exception
来源:互联网 发布:mysql和redis 的结合 编辑:程序博客网 时间:2024/05/16 16:01
在使用hibernate将查询出的数据映射到实体类时,出现映射错误,原因是有些特殊类型的字段不能直接进行映射,比如image等
解决方法,spring配置文件中,"sessionFactory"bean的有一项hibernate.dialect,是指定hibernate所使用的方言的,他的值可以写到一个自定义的property文件中,内容如下
#sessionFactory
#hibernate.dialect = org.hibernate.dialect.SQLServerDialect
hibernate.dialect = cpcns.gongyongzujian.util.MySQLServerDialect
#hibernate.show_sql = false;
hibernate.show_sql = true;
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingJarLocations">
<list>
<value>WEB-INF/lib/cpcns_base.jar</value>
<value>WEB-INF/lib/CPCNS_ZuJianBase.jar</value>
</list>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/cpcns/gongyongzujian/wenjianchuanshu/model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.connection.autocommit">true</prop>
<prop key="hibernate.connection.release_mode">after_statement</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
</props>
</property>
</bean>
我们可以继承它的SQLServerDialect类,在自己定义的类里做下转换
public class MySQLServerDialect extends SQLServerDialect{
public MySQLServerDialect() {
super();
registerHibernateType(Types.LONGVARBINARY, Hibernate.BLOB.getName());
}
}
同时将hibernate.dialect 的值改为 cpcns.gongyongzujian.util.MySQLServerDialect,及在.property中如下设置
hibernate.dialect = cpcns.gongyongzujian.util.MySQLServerDialect
- hibernate model mapping exception
- org.hibernate.exception.SQLGrammarException: could notinsert: [com.michael.model.Storen]
- hibernate-mapping
- Hibernate mapping
- 关于hibernate中报Duplicate class/entity mapping org.model.User错的问题
- Could not determine type for: model.Student, at table: Contact, for columns: [org.hibernate.mapping.
- nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from inp
- The Exception Model
- hibernate exception
- Hibernate exception
- nested exception is org.hibernate.MappingException: entity class not found: com.model.TLiuyan
- nested exception is org.hibernate.MappingException: entity class not found: com.model.TLiuyan
- org.hibernate.exception.ConstraintViolationException: could not delete: [org.jbpm.pvm.internal.model
- Exception in thread "main" org.hibernate.MappingNotFoundException: resource: com.xzhl.user.model/Stu
- Exception in thread "main" org.hibernate.MappingException: Unknown entity: org.model.Kcb
- Javassist Enhancement failed: model.AttendType; nested exception is org.hibernate.HibernateException
- 自己创建 hibernate mapping
- Hibernate Mapping笔记
- HashMap和Hasptable的区别
- 负载均衡解决方案
- saas与云计算的区别
- Java JUnit简单例子 JUnit4
- android 编译单个模块
- hibernate model mapping exception
- 安装飞信
- 【Android-Emulator】Android模拟器介绍和基本使用
- SDRAM和DDR SDRAM时序图与信号完整性仿真结合运用(2)
- C# winform中ListView用法
- PDF开发库荟萃
- 作为软件开发人员应该知道的最基本的东西
- win32串口编程
- java面向对象下