HHH-6580 - Discriminator value used as ID when inserting entity to PosgtreSQL
This commit is contained in:
parent
830d4cd2ab
commit
253cb0a9d3
|
@ -33,6 +33,12 @@ import javax.persistence.Entity;
|
|||
@Entity
|
||||
@DiscriminatorValue("1")
|
||||
public class InheritingEntity extends ParentEntity {
|
||||
public InheritingEntity() {
|
||||
}
|
||||
|
||||
public InheritingEntity(String someValue) {
|
||||
this.someValue = someValue;
|
||||
}
|
||||
|
||||
@Column(name = "dupa")
|
||||
private String someValue;
|
||||
|
|
|
@ -44,15 +44,16 @@ public class PersistChildEntitiesWithDiscriminatorTest extends BaseCoreFunctiona
|
|||
public void doIt() {
|
||||
Session session = openSession();
|
||||
session.beginTransaction();
|
||||
InheritingEntity child = new InheritingEntity();
|
||||
child.setSomeValue("blabla");
|
||||
session.save(child);
|
||||
// we need the 2 inserts so that the id is incremented on the second get-generated-keys-result set, since
|
||||
// on the first insert both the pk and the discriminator values are 1
|
||||
session.save( new InheritingEntity( "yabba" ) );
|
||||
session.save( new InheritingEntity( "dabba" ) );
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
session = openSession();
|
||||
session.beginTransaction();
|
||||
session.delete( child );
|
||||
session.createQuery( "delete ParentEntity" ).executeUpdate();
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue