I have encountered a strange error with hibernate, most likely due to improper use of it, but I was wondering if there is any way to find the root cause of it and perhaps remedy it.
Currently I have a class hierarchy that looks like:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "tbl_class_a)
public ClassA {
...
private int propA;
...
}
@Entity
@Table(name = "tbl_class_b")
public ClassB extends ClassA {
...
@Column(unique = true)
private int propB;
...
}
@Entity
@Table(name = "tbl_class_c")
public ClassC extends ClassC {
...
private int propC;
...
}
I have extensively tested the persistence and deletion of objects of all three classes and everything seems to perform normally until I consider the constraints on the properties, esp. with regard to persistence.
Now I instantiate an object, newObj, of Class C that has a value of propB that is equal to an all ready persisted object that all ready has that value for its propB. I try to persist it, and as expected, a constraint violation is thrown and I attempt to roll back the transaction. I would expect that all traces of newObj would be removed, but something extremely strange happens. All references to newObj in the tables for Class C and Class B are indeed removed, but the properties in the table for Class A remain, and as far as I can tell irretrievable. Why??