案例:
执行如下语句:
select 'CRM' System, t.* from test t;
通过Hibernate执行时,取到的system是字符'C',并非'CRM'
解决方案:
1、sql语句改为select decode(1,1,'CRM') as System,t.* from test t;
2、sql语句改为select cast('CRM' as varchar2(3)) as System,t.* from test t;
3、继承一个Dialect,注册CHAR类型的对应方式
执行如下语句:
select 'CRM' System, t.* from test t;
通过Hibernate执行时,取到的system是字符'C',并非'CRM'
解决方案:
1、sql语句改为select decode(1,1,'CRM') as System,t.* from test t;
2、sql语句改为select cast('CRM' as varchar2(3)) as System,t.* from test t;
3、继承一个Dialect,注册CHAR类型的对应方式
public class OracleDialect extends org.hibernate.dialect.SQLServerDialect
{
public OracleDialect()
{
super();
registerHibernateType(Types.CHAR, Hibernate.STRING.getName());
}
}