我有以下映射:
<id name="id" type="java.lang.Long" column="id"> <generator class="sequence"> <param name="sequence">tracksdata_seq</param> </generator> </id>
当我在Hibernate 4.2中使用它时,一切都很顺利.现在我正在迁移到Hibernate 5并面临以下问题:
2015-10-06 19:49:50 DEBUG sql:92 - select nextval ('hibernate_sequence') 2015-10-06 19:49:50 DEBUG sqlExceptionHelper:122 - could not extract ResultSet [n/a] org.postgresql.util.PsqlException: ERROR: relation "hibernate_sequence" does not exist
如何解决这个问题?
附: Hibernate 5.0.2.Final.
解决方法
你有两个选择:
>您将hibernate.id.new_generator_mappings配置属性设置为false并切换回旧的标识符生成器
>您可以按如下方式更改映射:
<generator class="sequence"> <param name="sequence">MY_SEQUENCE</param> </generator>
至:
<generator class="org.hibernate.id.enhanced.SequenceStyleGenerator"> <param name="optimizer">none</param> <param name="increment_size">1</param> <param name="sequence_name">MY_SEQUENCE</param> </generator>