日期:2014-05-16 浏览次数:20645 次
package com.asl.cityu.common; import java.sql.Types; import org.hibernate.Hibernate; import org.hibernate.dialect.SQLServerDialect; public class SqlServer2008Dialect extends SQLServerDialect { public SqlServer2008Dialect() { super(); registerHibernateType(1, "string"); registerHibernateType(-9, "string"); registerHibernateType(-16, "string"); registerHibernateType(3, "double"); registerHibernateType(Types.CHAR, Hibernate.STRING.getName()); registerHibernateType(Types.NVARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.LONGNVARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.DECIMAL, Hibernate.DOUBLE.getName()); } }
<?xml version="1.0" encoding="UTF-8" ?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="DateSource"> <jta-data-source>java:/SqlServerDS</jta-data-source> <properties> <property name="hibernate.dialect" value="com.asl.cityu.common.SqlServer2008Dialect"/> <property name="hibernate.hbm2ddl.auto" value="none" /> </properties> </persistence-unit> </persistence>