The Oracle9Dialect dialect has been deprecated; use either Oracle9iDialect or Oracle10gDialect instead
那是因为 Dialect 未定义,重写类,把未定义的Dialect 注册一下即可,
并且在 hibernate.cfg.xml中加入
<property name="hibernate.dialect">
org.hibernate.dialect.OracleCustomDialect
</property>
新建一个类叫OracleCustomDialect
protected Dialect() {
log.info( "Using dialect: " + this );
sqlFunctions.putAll( STANDARD_AGGREGATE_FUNCTIONS );
// standard sql92 functions (can be overridden by subclasses)
registerFunction( "substring", new SQLFunctionTemplate( Hibernate.STRING, "substring(?1, ?2, ?3)" ) );
registerFunction( "locate", new SQLFunctionTemplate( Hibernate.INTEGER, "locate(?1, ?2, ?3)" ) );
registerFunction( "trim", new SQLFunctionTemplate( Hibernate.STRING, "trim(?1 ?2 ?3 ?4)" ) );
registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
registerFunction( "bit_length", new StandardSQLFunction( "bit_length", Hibernate.INTEGER ) );
registerFunction( "coalesce", new StandardSQLFunction( "coalesce" ) );
registerFunction( "nullif", new StandardSQLFunction( "nullif" ) );
registerFunction( "abs", new StandardSQLFunction( "abs" ) );
registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER) );
registerFunction( "sqrt", new StandardSQLFunction( "sqrt", Hibernate.DOUBLE) );
让Hibernate支持Oracle中的函数
最新推荐文章于 2021-04-05 05:50:49 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)