禁用上下文LOB创建为createClob()方法引发错误:java.lang.reflect.InvocationTargetException

时间:2017-07-23 18:37:22

标签: java postgresql hibernate postgresql-9.3 postgresql-9.2

我将hibernate配置为使用Posgresql

<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQL92Dialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>

但是当我启动tomcat时我会遇到异常:

23-Jul-2017 21:22:25.544 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 7529 ms
23-Jul-2017 21:26:47.901 INFO [http-nio-8081-exec-9] org.hibernate.Version.logVersion HHH000412: Hibernate Core {5.2.10.Final}
23-Jul-2017 21:26:47.912 INFO [http-nio-8081-exec-9] org.hibernate.cfg.Environment.<clinit> HHH000206: hibernate.properties not found
23-Jul-2017 21:26:48.546 INFO [http-nio-8081-exec-9] org.hibernate.annotations.common.reflection.java.JavaReflectionManager.<clinit> HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
23-Jul-2017 21:26:49.840 INFO [http-nio-8081-exec-9] org.hibernate.dialect.Dialect.<init> HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL92Dialect
23-Jul-2017 21:26:50.021 INFO [http-nio-8081-exec-9] org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl.useContextualLobCreation HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
23-Jul-2017 21:26:50.024 INFO [http-nio-8081-exec-9] org.hibernate.type.BasicTypeRegistry.register HHH000270: Type registration [java.util.UUID] overrides previous : org.hibernate.type.UUIDBinaryType@4bbde374
Hibernate: 

当我在Postgresql表中插入记录时,行是空的。 我如何正确配置Hibernate?

2 个答案:

答案 0 :(得分:1)

此异常由Hibernate抛出,与Spring Boot或您的实现无关。您可以按照link中的说明通过修改application.properties来抑制此错误。

答案 1 :(得分:-1)

嗯,它通过以下输出成功地为我工作:

objArray = [
  {"date":"07/19/2017 12:00:00 AM","count":"1000","code":"K100"},
  {"date":"07/21/2017 12:00:00 AM","count":"899","code":"C835"},
  {"date":"07/23/2017 12:00:00 AM","count":"700","code":"C837"},
  {"date":"07/23/2017 12:00:00 AM","count":"800","code":"K100"},
  {"date":"07/23/2017 12:00:00 AM","count":"50","code":"C837"}
];


var objs = objArray.reduce((obj, rec) => {
  if (obj[rec.date] === undefined) {
    rec.code = [rec.code];
    rec.count = Number(rec.count);
    obj[rec.date] = rec;
  } else {
    obj[rec.date].count += Number(rec.count);
    obj[rec.date].code.push(rec.code);
  }
  return obj;
}, {}) 

console.log(Object.values(objs));

我使用了以下xml文件:

> log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
> log4j:WARN Please initialize the log4j system properly.
Hibernate: 

    insert 
    into
        emp
        (firstName, lastName, id) 
    values
        (?, ?, ?)
Trasaction completed successfully using config!

请尝试在代码中使用XML文件。 注意:请注意Hibernate版本。