Spring Hibernate MySQL默认列默认值

时间:2018-11-09 20:16:35

标签: java mysql spring hibernate

我在表中有一些列,这些列在mysql中给出了一些默认值。我希望能够使用在使用Java hibernate运行的查询中设置的默认值

我有这个代码

 String updated_value = (String)query.uniqueResult();

@SuppressWarnings({
"rawtypes",
"deprecation"
})
Query theQuery = currentSession.createSQLQuery("update trades set trade_end_value = ?1 ,trade_status = 'DONE', trade_end_value_worker_status ='DONE' where trade_end_value_worker_status='UNDONE' AND trade_status='UNDONE'");
             theQuery.setParameter(1, updated_value);
             theQuery.executeUpdate();

当我尝试在mysql工作台上运行代码时,它会运行并更新,但是当我在java内部执行时,会出现此错误

  

java.util.NoSuchElementException           在java.util.StringTokenizer.nextToken(StringTokenizer.java:349)           在org.hibernate.engine.jdbc.internal.BasicFormatterImpl $ FormatProcess.perform(BasicFormatterImpl.java:118)           在org.hibernate.engine.jdbc.internal.BasicFormatterImpl.format(BasicFormatterImpl.java:75)           在org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:89)           在org.hibernate.engine.jdbc.spi.SqlStatementLogger.logStatement(SqlStatementLogger.java:77)           在org.hibernate.engine.jdbc.internal.StatementPreparerImpl $ StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:167)上           在org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)           在org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1995)           在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1925)           在org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903)           在org.hibernate.loader.Loader.doQuery(Loader.java:948)           在org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:351)           在org.hibernate.loader.Loader.doList(Loader.java:2702)           在org.hibernate.loader.Loader.doList(Loader.java:2685)           在org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2517)           在org.hibernate.loader.Loader.list(Loader.java:2512)

0 个答案:

没有答案