Skip to content

Commit 1b07607

Browse files
committed
HHH-8318 test case
1 parent 363a3b2 commit 1b07607

File tree

5 files changed

+181
-1
lines changed

5 files changed

+181
-1
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.hibernate.test.annotations.query;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
import javax.persistence.Entity;
7+
import javax.persistence.GeneratedValue;
8+
import javax.persistence.Id;
9+
import javax.persistence.JoinTable;
10+
import javax.persistence.OneToMany;
11+
12+
@Entity
13+
public class Attrset {
14+
@Id
15+
@GeneratedValue
16+
private Long id;
17+
18+
@OneToMany
19+
@JoinTable(name = "ATTRSET_X_ATTRVALUE")
20+
private Set<Attrvalue> attrvalues = new HashSet<Attrvalue>();
21+
22+
public Long getId() {
23+
return id;
24+
}
25+
26+
public void setId(Long id) {
27+
this.id = id;
28+
}
29+
30+
public Set<Attrvalue> getAttrvalues() {
31+
return attrvalues;
32+
}
33+
34+
public void setAttrvalues(Set<Attrvalue> attrvalues) {
35+
this.attrvalues = attrvalues;
36+
}
37+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.hibernate.test.annotations.query;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
7+
@Entity
8+
public class Attrvalue {
9+
@Id
10+
@GeneratedValue
11+
private Long id;
12+
13+
private String value;
14+
15+
public Long getId() {
16+
return id;
17+
}
18+
19+
public void setId(Long id) {
20+
this.id = id;
21+
}
22+
23+
public String getValue() {
24+
return value;
25+
}
26+
27+
public void setValue(String value) {
28+
this.value = value;
29+
}
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.hibernate.test.annotations.query;
2+
3+
import javax.persistence.Entity;
4+
import javax.persistence.GeneratedValue;
5+
import javax.persistence.Id;
6+
import javax.persistence.ManyToOne;
7+
8+
@Entity
9+
public class Employee {
10+
@Id
11+
@GeneratedValue
12+
private Long id;
13+
14+
@ManyToOne
15+
private Employeegroup employeegroup;
16+
17+
@ManyToOne
18+
private Attrset attrset;
19+
20+
public Long getId() {
21+
return id;
22+
}
23+
24+
public void setId(Long id) {
25+
this.id = id;
26+
}
27+
28+
public Employeegroup getEmployeegroup() {
29+
return employeegroup;
30+
}
31+
32+
public void setEmployeegroup(Employeegroup employeegroup) {
33+
this.employeegroup = employeegroup;
34+
}
35+
36+
public Attrset getAttrset() {
37+
return attrset;
38+
}
39+
40+
public void setAttrset(Attrset attrset) {
41+
this.attrset = attrset;
42+
}
43+
44+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.hibernate.test.annotations.query;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
import javax.persistence.CascadeType;
7+
import javax.persistence.Entity;
8+
import javax.persistence.GeneratedValue;
9+
import javax.persistence.Id;
10+
import javax.persistence.ManyToOne;
11+
import javax.persistence.OneToMany;
12+
13+
@Entity
14+
public class Employeegroup {
15+
@Id
16+
@GeneratedValue
17+
private Long id;
18+
19+
@OneToMany(cascade = CascadeType.ALL, mappedBy = "employeegroup")
20+
private List<Employee> employees = new ArrayList<Employee>();
21+
22+
@ManyToOne
23+
private Attrset attrset;
24+
25+
public Long getId() {
26+
return id;
27+
}
28+
29+
public void setId(Long id) {
30+
this.id = id;
31+
}
32+
33+
public List<Employee> getEmployees() {
34+
return employees;
35+
}
36+
37+
public void setEmployees(List<Employee> employees) {
38+
this.employees = employees;
39+
}
40+
41+
public Attrset getAttrset() {
42+
return attrset;
43+
}
44+
45+
public void setAttrset(Attrset attrset) {
46+
this.attrset = attrset;
47+
}
48+
49+
}

hibernate-core/src/test/java/org/hibernate/test/annotations/query/QueryAndSQLTest.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.hibernate.test.annotations.Plane;
4747
import org.hibernate.testing.FailureExpected;
4848
import org.hibernate.testing.SkipForDialect;
49+
import org.hibernate.testing.TestForIssue;
4950
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
5051

5152
import static org.junit.Assert.assertEquals;
@@ -452,6 +453,21 @@ public void testCollectionSQLOverriding() {
452453
tx.rollback();
453454
s.close();
454455
}
456+
457+
@Test
458+
@TestForIssue( jiraKey = "HHH-8318" )
459+
@FailureExpected( jiraKey = "HHH-8318" )
460+
public void testDeleteMemberOf() {
461+
Session s = openSession();
462+
s.getTransaction().begin();
463+
s.createQuery(
464+
"delete Attrvalue aval where aval.id in ( "
465+
+ "select val2.id from Employee e, Employeegroup eg, Attrset aset, Attrvalue val2 "
466+
+ "where eg.id = e.employeegroup.id " + "and aset.id = e.attrset.id "
467+
+ "and val2.id member of aset.attrvalues)" ).executeUpdate();
468+
s.getTransaction().commit();
469+
s.close();
470+
}
455471

456472
@Override
457473
protected Class[] getAnnotatedClasses() {
@@ -469,7 +485,11 @@ protected Class[] getAnnotatedClasses() {
469485
Captain.class,
470486
Chaos.class,
471487
CasimirParticle.class,
472-
AllTables.class
488+
AllTables.class,
489+
Attrset.class,
490+
Attrvalue.class,
491+
Employee.class,
492+
Employeegroup.class
473493
};
474494
}
475495

0 commit comments

Comments
 (0)