From 1b076074b051c1c8a46215546ca58456864ebd76 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 18 Jun 2013 13:33:45 -0400 Subject: [PATCH] HHH-8318 test case --- .../test/annotations/query/Attrset.java | 37 ++++++++++++++ .../test/annotations/query/Attrvalue.java | 30 ++++++++++++ .../test/annotations/query/Employee.java | 44 +++++++++++++++++ .../test/annotations/query/Employeegroup.java | 49 +++++++++++++++++++ .../annotations/query/QueryAndSQLTest.java | 22 ++++++++- 5 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrset.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrvalue.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employee.java create mode 100644 hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employeegroup.java diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrset.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrset.java new file mode 100644 index 0000000000..d3f9344eb0 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrset.java @@ -0,0 +1,37 @@ +package org.hibernate.test.annotations.query; + +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.JoinTable; +import javax.persistence.OneToMany; + +@Entity +public class Attrset { + @Id + @GeneratedValue + private Long id; + + @OneToMany + @JoinTable(name = "ATTRSET_X_ATTRVALUE") + private Set attrvalues = new HashSet(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Set getAttrvalues() { + return attrvalues; + } + + public void setAttrvalues(Set attrvalues) { + this.attrvalues = attrvalues; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrvalue.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrvalue.java new file mode 100644 index 0000000000..2d0ef1a8ca --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Attrvalue.java @@ -0,0 +1,30 @@ +package org.hibernate.test.annotations.query; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +public class Attrvalue { + @Id + @GeneratedValue + private Long id; + + private String value; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employee.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employee.java new file mode 100644 index 0000000000..acc69e841b --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employee.java @@ -0,0 +1,44 @@ +package org.hibernate.test.annotations.query; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; + +@Entity +public class Employee { + @Id + @GeneratedValue + private Long id; + + @ManyToOne + private Employeegroup employeegroup; + + @ManyToOne + private Attrset attrset; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Employeegroup getEmployeegroup() { + return employeegroup; + } + + public void setEmployeegroup(Employeegroup employeegroup) { + this.employeegroup = employeegroup; + } + + public Attrset getAttrset() { + return attrset; + } + + public void setAttrset(Attrset attrset) { + this.attrset = attrset; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employeegroup.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employeegroup.java new file mode 100644 index 0000000000..020b5021dd --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/Employeegroup.java @@ -0,0 +1,49 @@ +package org.hibernate.test.annotations.query; + +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +@Entity +public class Employeegroup { + @Id + @GeneratedValue + private Long id; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "employeegroup") + private List employees = new ArrayList(); + + @ManyToOne + private Attrset attrset; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public List getEmployees() { + return employees; + } + + public void setEmployees(List employees) { + this.employees = employees; + } + + public Attrset getAttrset() { + return attrset; + } + + public void setAttrset(Attrset attrset) { + this.attrset = attrset; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java index 5ce992d572..8a0223d56e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java @@ -46,6 +46,7 @@ import org.hibernate.test.annotations.A320b; import org.hibernate.test.annotations.Plane; import org.hibernate.testing.FailureExpected; import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -452,6 +453,21 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase { tx.rollback(); s.close(); } + + @Test + @TestForIssue( jiraKey = "HHH-8318" ) + @FailureExpected( jiraKey = "HHH-8318" ) + public void testDeleteMemberOf() { + Session s = openSession(); + s.getTransaction().begin(); + s.createQuery( + "delete Attrvalue aval where aval.id in ( " + + "select val2.id from Employee e, Employeegroup eg, Attrset aset, Attrvalue val2 " + + "where eg.id = e.employeegroup.id " + "and aset.id = e.attrset.id " + + "and val2.id member of aset.attrvalues)" ).executeUpdate(); + s.getTransaction().commit(); + s.close(); + } @Override protected Class[] getAnnotatedClasses() { @@ -469,7 +485,11 @@ public class QueryAndSQLTest extends BaseCoreFunctionalTestCase { Captain.class, Chaos.class, CasimirParticle.class, - AllTables.class + AllTables.class, + Attrset.class, + Attrvalue.class, + Employee.class, + Employeegroup.class }; }