HHH-14279 Testcase showing key join order is messed up
This commit is contained in:
parent
6b58d54057
commit
4ffb768a7a
|
@ -0,0 +1,28 @@
|
|||
package org.hibernate.test.jpa;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
@Entity
|
||||
public class MapContent {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
@ManyToOne(optional = false)
|
||||
private Relationship relationship;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Relationship getRelationship() {
|
||||
return relationship;
|
||||
}
|
||||
public void setRelationship(Relationship relationship) {
|
||||
this.relationship = relationship;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package org.hibernate.test.jpa;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.MapKey;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
@Entity
|
||||
public class MapOwner {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
@MapKey(name = "relationship")
|
||||
private Map<Relationship, MapContent> contents;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Map<Relationship, MapContent> getContents() {
|
||||
return contents;
|
||||
}
|
||||
public void setContents(Map<Relationship, MapContent> contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package org.hibernate.test.jpa;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Relationship {
|
||||
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.jpa.ql;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.test.jpa.AbstractJPATest;
|
||||
import org.hibernate.test.jpa.MapContent;
|
||||
import org.hibernate.test.jpa.MapOwner;
|
||||
import org.hibernate.test.jpa.Relationship;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MapIssueTest extends AbstractJPATest {
|
||||
|
||||
@Override
|
||||
public String[] getMappings() {
|
||||
return new String[] {};
|
||||
}
|
||||
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] { MapOwner.class, MapContent.class, Relationship.class};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWhereSubqueryMapKeyIsEntityWhereWithKey() {
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
s.createQuery( "select r from Relationship r where exists (select 1 from MapOwner as o left join o.contents c with key(c) = r)" ).list();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapKeyIsEntityWhereWithKey() {
|
||||
Session s = openSession();
|
||||
s.beginTransaction();
|
||||
s.createQuery( "select 1 from MapOwner as o left join o.contents c where c.id is not null" ).list();
|
||||
s.getTransaction().commit();
|
||||
s.close();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue