1.
import java.sql.Types;
import org.hibernate.dialect.MySQLDialect;
public class MyDialect extends MySQLDialect{
public MyDialect(){
super();
registerHibernateType(Types.LONGVARCHAR, 65535, "text");
}
}
修改Hibernate配置文件hibernate.cfg.xml,把
<prop key="dialect">com.exception.MyDialect</prop>
2.SQLQuery query = session.createSQLQuery(sql).addScalar("h.TERMINAL_ID", Hibernate.STRING).addScalar("h.code", Hibernate.STRING).addScalar("h.area", Hibernate.STRING).addScalar("h.name", Hibernate.STRING).addScalar("h.region", Hibernate.STRING).addScalar("h.address", Hibernate.STRING).addScalar("h.type", Hibernate.STRING).addScalar("h.type_name", Hibernate.STRING).addScalar("h.MARK_NUM", Hibernate.STRING).addScalar("i.stops", Hibernate.STRING); 可以解决