HHH-8318 test case

This commit is contained in:
Brett Meyer 2013-06-18 13:33:45 -04:00
parent 363a3b2b58
commit 1b076074b0
5 changed files with 181 additions and 1 deletions

View File

@ -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<Attrvalue> attrvalues = new HashSet<Attrvalue>();
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Set<Attrvalue> getAttrvalues() {
return attrvalues;
}
public void setAttrvalues(Set<Attrvalue> attrvalues) {
this.attrvalues = attrvalues;
}
}

View File

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

View File

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

View File

@ -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<Employee> employees = new ArrayList<Employee>();
@ManyToOne
private Attrset attrset;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<Employee> getEmployees() {
return employees;
}
public void setEmployees(List<Employee> employees) {
this.employees = employees;
}
public Attrset getAttrset() {
return attrset;
}
public void setAttrset(Attrset attrset) {
this.attrset = attrset;
}
}

View File

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