刘政道 - 应用程序框架

《31天学会CRM项目开发(C#编程入门及项目实战)》作者,IT经理,程序员
  博客园  :: 新随笔  :: 联系 :: 管理

How to extend MySQLInnoDBDialect?

Posted on 2009-10-10 08:19  刘政道  阅读(284)  评论(0)    收藏  举报

I want my hibernate support Mysql Text type. But i get the error:


org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)


I search by google, I find this method is valid.


{codecitation class="brush: java; gutter: true;"}
package ceapet.jbpm;

import org.hibernate.Hibernate;
import org.hibernate.dialect.MySQLInnoDBDialect;

import java.sql.Types;

public class ExtMySQLInnoDBDialect extends MySQLInnoDBDialect {
public ExtMySQLInnoDBDialect()
{
super();
registerHibernateType(-1,Hibernate.TEXT.getName());
}
}
{/codecitation}


Than modify hibernate.xml


org.hibernate.dialect.MySQLInnoDBDialect

to

ceapet.jbpm.ExtMySQLInnoDBDialect