mysql方言不支持blob类型解决方案
package com.gstone.history.entity;
import java.sql.Types;
import org.hibernate.Hibernate; import org.hibernate.dialect.MySQLDialect;
public class BlobMySQLDialect extends MySQLDialect{ public BlobMySQLDialect(){ super(); registerHibernateType(Types.LONGVARBINARY, Hibernate.BLOB.getName()); } }
然后在配置文件中,改方言:
<prop key="hibernate.dialect">
com.gstone.history.entity.BlobMySQLDialect
</prop>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="packagesToScan" value="com.gstone"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.show_sql">false</prop>
<prop key="hibernate.dialect">
com.gstone.history.entity.BlobMySQLDialect
</prop>
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.cache.provider_configuration_file_resource_path">
spring/ehcache.xml
</prop>
</props>
</property>
</bean>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。