我正在执行 hibernate jpa 批量更新,它给我以下错误
2015-04-21 15:53:51,907 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (Thread-283 (HornetQ-client-global-threads-462057890)) SQL Error: 0, SQLState: 42P01
2015-04-21 15:53:51,908 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (Thread-283 (HornetQ-client-global-threads-462057890)) ERROR: relation "my_seq_gen" does not exist
我使用 postgres 数据库和我的 ID 是自动生成的
@Id
@SequenceGenerator(name="seq-gen",sequenceName="MY_SEQ_GEN"initialValue=205, allocationSize=12)
@GeneratedValue(strategy= GenerationType.SEQUENCE, generator="seq-gen")
@Column(name="\"ID\"",unique=true,nullable=false)
private int id;
这是我的批处理插入代码片段
getEm().getTransaction().begin();
System.out.println("transaction started--------------");
try {
for (Receipt ReceiptEntity : arrReceiptEntity) {
getEm().persist(ReceiptEntity);
}
getEm().getTransaction().commit();
System.out.println("commited");
} catch (Exception exception) {
System.out.println("error----------------------------------------------------------------------");
if(getEm().getTransaction().isActive())
getEm().getTransaction().rollback();
LOG.error(exception);
} finally {
getEm().flush();
getEm().clear();
getEm().close();
}
我已经将下面的属性添加到尾部
<property name="hibernate.id.new_generator_mappings" value="true"/>
请指出我做错了什么。