parent
2256b3761c
commit
140de50a95
|
@ -11,11 +11,14 @@ import javax.persistence.Embeddable;
|
||||||
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.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
@ -42,6 +45,7 @@ public class CollectionMapWithComponentValueTest extends BaseCoreFunctionalTestC
|
||||||
@Override
|
@Override
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
return new Class[] {
|
return new Class[] {
|
||||||
|
BaseTestEntity.class,
|
||||||
TestEntity.class,
|
TestEntity.class,
|
||||||
KeyValue.class
|
KeyValue.class
|
||||||
};
|
};
|
||||||
|
@ -54,14 +58,20 @@ public class CollectionMapWithComponentValueTest extends BaseCoreFunctionalTestC
|
||||||
{
|
{
|
||||||
s.save( keyValue );
|
s.save( keyValue );
|
||||||
|
|
||||||
|
BaseTestEntity baseTestEntity1 = new BaseTestEntity();
|
||||||
TestEntity testEntity = new TestEntity();
|
TestEntity testEntity = new TestEntity();
|
||||||
Map<KeyValue, EmbeddableValue> map = new HashMap<>();
|
Map<KeyValue, EmbeddableValue> map = new HashMap<>();
|
||||||
map.put( keyValue, embeddableValue );
|
map.put( keyValue, embeddableValue );
|
||||||
testEntity.values = map;
|
testEntity.values = map;
|
||||||
s.save( testEntity );
|
s.save( testEntity );
|
||||||
|
baseTestEntity1.entities = new HashSet<TestEntity>();
|
||||||
|
baseTestEntity1.entities.add( testEntity );
|
||||||
|
s.save( baseTestEntity1 );
|
||||||
|
|
||||||
KeyValue keyValue2 = new KeyValue( "key2" );
|
KeyValue keyValue2 = new KeyValue( "key2" );
|
||||||
s.save( keyValue2 );
|
s.save( keyValue2 );
|
||||||
|
BaseTestEntity baseTestEntity2 = new BaseTestEntity();
|
||||||
|
s.save( baseTestEntity2 );
|
||||||
TestEntity testEntity2 = new TestEntity();
|
TestEntity testEntity2 = new TestEntity();
|
||||||
Map<KeyValue, EmbeddableValue> map2 = new HashMap<>();
|
Map<KeyValue, EmbeddableValue> map2 = new HashMap<>();
|
||||||
map.put( keyValue2, embeddableValue );
|
map.put( keyValue2, embeddableValue );
|
||||||
|
@ -203,11 +213,32 @@ public class CollectionMapWithComponentValueTest extends BaseCoreFunctionalTestC
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-10537")
|
||||||
|
public void testLeftJoinMapAndUseKeyExpression() {
|
||||||
|
doInHibernate( this::sessionFactory, s -> {
|
||||||
|
// Assert that a left join is used for joining the map key entity table
|
||||||
|
List keyValues= s.createQuery( "select key(v) from BaseTestEntity bte left join bte.entities te left join te.values v" ).list();
|
||||||
|
assertEquals( 2, keyValues.size() );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isCleanupTestDataRequired() {
|
protected boolean isCleanupTestDataRequired() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Entity(name = "BaseTestEntity")
|
||||||
|
@Table(name = "BASE_TEST_ENTITY")
|
||||||
|
public static class BaseTestEntity {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
Long id;
|
||||||
|
|
||||||
|
@OneToMany
|
||||||
|
Set<TestEntity> entities;
|
||||||
|
}
|
||||||
|
|
||||||
@Entity(name = "TestEntity")
|
@Entity(name = "TestEntity")
|
||||||
@Table(name = "TEST_ENTITY")
|
@Table(name = "TEST_ENTITY")
|
||||||
public static class TestEntity {
|
public static class TestEntity {
|
||||||
|
|
Loading…
Reference in New Issue