【spring boot hibernate】hibernate命名策略spring.jpa.hibernate.naming-strategy不起作用

对于

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

hibernate命名策略设置之后不起作用的处理方式:http://www.cnblogs.com/sxdcgaq8080/p/7890218.html,查看1.JPA hibernate命名策略即可

 

现在这里说一下原因,为什么不起作用:

  spring.jpa.hibernate.naming-strategy 设置命名策略,是hibernate4的命名策略,对于hibernate5是不起作用的。

查看自己项目中hibernate版本:

 

完整的spring boot配置可以查看:http://www.cnblogs.com/sxdcgaq8080/p/7724506.html

 

展开阅读全文

hibernate 命名查询问题

12-13

rnrnrnrn rn falsern rn rn rnrn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rn rnrnrn rnrn rn rn select rn userOrderForm_userIDrn from rn userOrderForm_tablern where rn userOrderForm_periodNo=:nowPeriodNornrn rn rn rnrnrn======================rnList orderlist = s.getNamedQuery("GetNeedBackOrderOrder")rn .setString("nowPeriodNo", perio)rn .list();rnrn报错:rnHibernate: select rn userOrderForm_userIDrn from rn userOrderForm_tablern where rn userOrderForm_periodNo=?rn14:57:32,828 INFO StringType:182 - could not read column value from result set: userOrderForm_ID; Invalid column name userOrderForm_ID.rnException in thread "main" org.hibernate.exception.SQLGrammarException: could not execute queryrn at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)rn at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)rn at org.hibernate.loader.Loader.doList(Loader.java:2223)rn at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)rn at org.hibernate.loader.Loader.list(Loader.java:2099)rn at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)rn at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)rn at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)rn at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)rn at com.hellobet.HibernateUtil.main(HibernateUtil.java:50)rnCaused by: java.sql.SQLException: Invalid column name userOrderForm_ID.rn at net.sourceforge.jtds.jdbc.JtdsResultSet.findColumn(JtdsResultSet.java:976)rn at net.sourceforge.jtds.jdbc.JtdsResultSet.getString(JtdsResultSet.java:1217)rn at org.hibernate.type.StringType.get(StringType.java:18)rn at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:163)rn at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:154)rn at org.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:1097)rn at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:565)rn at org.hibernate.loader.Loader.doQuery(Loader.java:701)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)rn at org.hibernate.loader.Loader.doList(Loader.java:2220)rn ... 7 morern 论坛

没有更多推荐了,返回首页