|
| 1 | +/* |
| 2 | + * Hibernate, Relational Persistence for Idiomatic Java |
| 3 | + * |
| 4 | + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. |
| 5 | + * See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>. |
| 6 | + */ |
| 7 | +package org.hibernate.test.jpa.ql; |
| 8 | + |
| 9 | +import java.util.Properties; |
| 10 | + |
| 11 | +import org.hibernate.cfg.AvailableSettings; |
| 12 | +import org.hibernate.cfg.Configuration; |
| 13 | +import org.hibernate.dialect.H2Dialect; |
| 14 | +import org.hibernate.persister.collection.QueryableCollection; |
| 15 | + |
| 16 | +import org.hibernate.testing.RequiresDialect; |
| 17 | +import org.hibernate.testing.TestForIssue; |
| 18 | +import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; |
| 19 | +import org.hibernate.test.jpa.MapContent; |
| 20 | +import org.hibernate.test.jpa.MapOwner; |
| 21 | +import org.hibernate.test.jpa.Relationship; |
| 22 | +import org.junit.Assert; |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +@RequiresDialect(H2Dialect.class) |
| 26 | +public class MapKeySubquerySchemaTest extends BaseCoreFunctionalTestCase { |
| 27 | + |
| 28 | + private static final String CUSTOM_SCHEMA = "CUSTOM_SCHEMA"; |
| 29 | + |
| 30 | + @Test |
| 31 | + @TestForIssue( jiraKey = "HHH-15523") |
| 32 | + public void testMapKeyLoad() { |
| 33 | + final QueryableCollection collectionPersister = (QueryableCollection) sessionFactory().getMetamodel() |
| 34 | + .collectionPersister( MapOwner.class.getName() + ".contents" ); |
| 35 | + Assert.assertEquals( |
| 36 | + "(select a1.relationship_id from " + CUSTOM_SCHEMA + ".MapContent a1 where a1.id=contents_id)", |
| 37 | + collectionPersister.getIndexFormulas()[0] |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + @Override |
| 42 | + protected void configure(Configuration configuration) { |
| 43 | + final Properties properties = new Properties(); |
| 44 | + properties.put( AvailableSettings.DEFAULT_SCHEMA, CUSTOM_SCHEMA ); |
| 45 | + configuration.addProperties( properties ); |
| 46 | + } |
| 47 | + |
| 48 | + @Override |
| 49 | + protected String createSecondSchema() { |
| 50 | + return CUSTOM_SCHEMA; |
| 51 | + } |
| 52 | + |
| 53 | + @Override |
| 54 | + protected Class[] getAnnotatedClasses() { |
| 55 | + return new Class[] { MapOwner.class, MapContent.class, Relationship.class}; |
| 56 | + } |
| 57 | +} |
0 commit comments