HHH-7187 - Manual flush mode and @PrimaryKeyJoinColumn tests

This commit is contained in:
Lukasz Antoniak 2012-04-16 23:18:11 +02:00 committed by Strong Liu
parent b8e356f966
commit c76810ac47
8 changed files with 31 additions and 6 deletions

View File

@ -56,6 +56,7 @@ public class DoubleFlushModDel extends AbstractFlushTest {
StrTestEntity fe = new StrTestEntity("x"); StrTestEntity fe = new StrTestEntity("x");
em.persist(fe); em.persist(fe);
em.flush();
em.getTransaction().commit(); em.getTransaction().commit();

View File

@ -56,6 +56,7 @@ public class DoubleFlushModMod extends AbstractFlushTest {
StrTestEntity fe = new StrTestEntity("x"); StrTestEntity fe = new StrTestEntity("x");
em.persist(fe); em.persist(fe);
em.flush();
em.getTransaction().commit(); em.getTransaction().commit();

View File

@ -56,6 +56,7 @@ public class ManualFlush extends AbstractFlushTest {
StrTestEntity fe = new StrTestEntity("x"); StrTestEntity fe = new StrTestEntity("x");
em.persist(fe); em.persist(fe);
em.flush();
em.getTransaction().commit(); em.getTransaction().commit();

View File

@ -1,12 +1,15 @@
package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn; package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.PrimaryKeyJoinColumn;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.envers.Audited; import org.hibernate.envers.Audited;
/** /**
@ -16,13 +19,16 @@ import org.hibernate.envers.Audited;
@Audited @Audited
public class Account implements Serializable { public class Account implements Serializable {
@Id @Id
@GeneratedValue @Column(name = "ACCOUNT_ID")
@GeneratedValue(generator = "AccountForeignKeyGenerator")
@GenericGenerator(name = "AccountForeignKeyGenerator", strategy = "foreign",
parameters = {@Parameter(name = "property", value = "owner")})
private Long accountId; private Long accountId;
private String type; private String type;
@OneToOne(optional = false) @OneToOne(optional = false)
@PrimaryKeyJoinColumn @PrimaryKeyJoinColumn(name = "ACCOUNT_ID", referencedColumnName = "PERSON_ID")
private Person owner; private Person owner;
public Account() { public Account() {

View File

@ -1,6 +1,7 @@
package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn; package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
@ -17,6 +18,7 @@ import org.hibernate.envers.RelationTargetAuditMode;
@Audited @Audited
public class AccountNotAuditedOwners implements Serializable { public class AccountNotAuditedOwners implements Serializable {
@Id @Id
@Column(name = "ACCOUNT_ID")
@GeneratedValue @GeneratedValue
private Long accountId; private Long accountId;

View File

@ -1,12 +1,15 @@
package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn; package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.PrimaryKeyJoinColumn;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Proxy; import org.hibernate.annotations.Proxy;
/** /**
@ -16,13 +19,16 @@ import org.hibernate.annotations.Proxy;
@Proxy(lazy = false) @Proxy(lazy = false)
public class NotAuditedNoProxyPerson implements Serializable { public class NotAuditedNoProxyPerson implements Serializable {
@Id @Id
@GeneratedValue @Column(name = "PERSON_ID")
@GeneratedValue(generator = "NotAuditedNoProxyKeyGenerator")
@GenericGenerator(name = "NotAuditedNoProxyKeyGenerator", strategy = "foreign",
parameters = {@Parameter(name = "property", value = "account")})
private Long personId; private Long personId;
private String name; private String name;
@OneToOne(optional = false) @OneToOne(optional = false)
@PrimaryKeyJoinColumn @PrimaryKeyJoinColumn(name = "PERSON_ID", referencedColumnName = "ACCOUNT_ID")
private AccountNotAuditedOwners account; private AccountNotAuditedOwners account;
public NotAuditedNoProxyPerson() { public NotAuditedNoProxyPerson() {

View File

@ -1,6 +1,7 @@
package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn; package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
@ -8,6 +9,8 @@ import javax.persistence.Id;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.PrimaryKeyJoinColumn;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.Proxy; import org.hibernate.annotations.Proxy;
/** /**
@ -17,13 +20,16 @@ import org.hibernate.annotations.Proxy;
@Proxy(lazy = true) @Proxy(lazy = true)
public class NotAuditedProxyPerson implements Serializable { public class NotAuditedProxyPerson implements Serializable {
@Id @Id
@GeneratedValue @Column(name = "PERSON_ID")
@GeneratedValue(generator = "NotAuditedProxyKeyGenerator")
@GenericGenerator(name = "NotAuditedProxyKeyGenerator", strategy = "foreign",
parameters = {@Parameter(name = "property", value = "account")})
private Long personId; private Long personId;
private String name; private String name;
@OneToOne(optional = false, fetch = FetchType.LAZY) @OneToOne(optional = false, fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn @PrimaryKeyJoinColumn(name = "PERSON_ID", referencedColumnName = "ACCOUNT_ID")
private AccountNotAuditedOwners account; private AccountNotAuditedOwners account;
public NotAuditedProxyPerson() { public NotAuditedProxyPerson() {

View File

@ -1,6 +1,7 @@
package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn; package org.hibernate.envers.test.integration.onetoone.bidirectional.primarykeyjoincolumn;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
@ -15,6 +16,7 @@ import org.hibernate.envers.Audited;
@Audited @Audited
public class Person implements Serializable { public class Person implements Serializable {
@Id @Id
@Column(name = "PERSON_ID")
@GeneratedValue @GeneratedValue
private Long personId; private Long personId;