HHH-6580 - Discriminator value used as ID when inserting entity to PosgtreSQL

This commit is contained in:
Steve Ebersole 2012-01-26 14:37:00 -06:00
parent 830d4cd2ab
commit 253cb0a9d3
2 changed files with 11 additions and 4 deletions

View File

@ -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;

View File

@ -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();
}