Reputation: 199
After upgrading from Hibernate 4.2 to 5.5.5 my inheritance isn't working anymore. Starting my application the following error is thrown:
ERROR AssertionFailure:33 - HHH000099: an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Table
BASE.ANIMAL
not found
here my classes:
cat.java
package ext;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="CAT", schema="EXT")
@Inheritance(strategy=InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name="ANIMALid", referencedColumnName="id")
public class CAT extends base.ANIMAL implements Serializable {
public CAT() {
}
public String toString() {
return super.toString();
}
}
animal.java
package base;
import java.io.Serializable;
import javax.persistence.*;
@Entity
@org.hibernate.annotations.Proxy(lazy=false)
@Table(name="ANIMAL", schema="BASE")
@Inheritance(strategy=InheritanceType.JOINED)
@DiscriminatorValue("ANIMAL")
public class ANIMAL implements Serializable {
public ANIMAL() {
}
@Column(name="id", nullable=false, unique=true, length=10)
@Id
@GeneratedValue(generator="BASE_ANIMAL_ID_GENERATOR")
@org.hibernate.annotations.GenericGenerator(name="BASE_ANIMAL_ID_GENERATOR", strategy="native", parameters={ @org.hibernate.annotations.Parameter(name="schema", value="BASE") })
private int id;
private void setId(int value) {
this.id = value;
}
public int getId() {
return id;
}
public int getORMID() {
return getId();
}
public String toString() {
return String.valueOf(getId());
}
}
testclass
package ormsamples;
import org.orm.*;
public class CreateJoinedinheritanceData {
public void createTestData() throws PersistentException {
PersistentTransaction t = ext.JoinedinheritancePersistentManager.instance().getSession().beginTransaction();
try {
base.ANIMAL bASEANIMAL = base.ANIMALDAO.createANIMAL();
// Initialize the properties of the persistent object here
base.ANIMALDAO.save(bASEANIMAL);
ext.CAT eXTCAT = ext.CATDAO.createCAT();
// Initialize the properties of the persistent object here
ext.CATDAO.save(eXTCAT);
t.commit();
}
catch (Exception e) {
t.rollback();
}
}
public static void main(String[] args) {
try {
CreateJoinedinheritanceData createJoinedinheritanceData = new CreateJoinedinheritanceData();
try {
createJoinedinheritanceData.createTestData();
}
finally {
ext.JoinedinheritancePersistentManager.instance().disposePersistentManager();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
have i missed a migration step or is there a bug in the latest hibernate 5 release?
looking forward for your suggestions!
Upvotes: 0
Views: 831
Reputation: 199
After doing some more research I ran into this hibernate bug HHH-10490.
It was rejected with the answer to use catalog
instead of schema
. Unfortunately no further explanation was given, but if I change this line
@Table(name="ANIMAL", schema="BASE")
to
@Table(name="ANIMAL", catalog="BASE")
everything works fine again.
Similarly to this post, also described by bug author here.
Upvotes: 1