Reputation: 1555
I have a question that is similar to this question but in a slightly different way that makes all the difference.
My problem is that I'm in the process of migrating a project portfolio from Java 8/Hibernate 4.x stack to a Java 11/Hibernate 5.4 stack.
In the second case, I get this error as soon as the application tries to save an object:
org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist
The answers to the other question I mentioned above provided some insight but I'm still not understanding why that error occurs: all of our entities have been using each his own sequence and the sequence is clearly specified in the corresponding hbm.xml. Here is one such mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping default-lazy="false">
<class name="…" table="data_receiving">
<id name="systemId" column="system_id">
<generator class="sequence">
<param name="sequence">system_id_seq</param>
</generator>
</id>
<property name="source" column="source" />
…
</class>
</hibernate-mapping>
It looks like the specification of the sequence is being ignored. I've looked up some documentation of the legacy Hibernate mapping with XML, but I could not find anything related to Hibernate 5, which reportedly still supports such mappings.
A solution could have been to migrate altogether to annotations, but the portfolio contains a dozen of applications which have scores of tables and a total number (in one application) of columns over 1200. The task is simply impractical, all the more since some applications are being rewritten from scratch as microservices.
My question is whether the specification of a sequence-generated identifier that I've is still supported?
Upvotes: 2
Views: 1232
Reputation: 1555
I have had to delve into the source code of Hibernate to find that one out: parameter sequence
has been renamed to sequence_name
.
<param name="sequence">system_id_seq</param>
must now be
<param name="sequence_name">system_id_seq</param>
This makes it necessary to update all hbm.xml files, which I did using a find and replace in Eclipse.
Upvotes: 5