Re-enabled additional tests
This commit is contained in:
parent
fcda293c5e
commit
36be5cc3da
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.jpa.test.mapping;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Emmanuel Bernard
|
|
||||||
*/
|
|
||||||
public class QuotingTest extends BaseEntityManagerFunctionalTestCase {
|
|
||||||
@Test
|
|
||||||
@Ignore("don't know what this test doing, just ignore it for now --stliu")
|
|
||||||
public void testQuote() {
|
|
||||||
// the configuration was failing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getEjb3DD() {
|
|
||||||
return new String[] {
|
|
||||||
"org/hibernate/ejb/test/mapping/orm.xml"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
|
||||||
return new Class<?>[] {
|
|
||||||
Phone.class
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
* 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
|
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.boot.database.qualfiedTableNaming;
|
package org.hibernate.orm.test.boot.database.qualfiedTableNaming;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.formulajoin;
|
package org.hibernate.orm.test.formulajoin;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
|
@ -4,19 +4,19 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.formulajoin;
|
package org.hibernate.orm.test.formulajoin;
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class AnnotatedFormWithBeanValidationNotNullTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class AnnotatedFormWithBeanValidationNotNullTest {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-8167" )
|
@TestForIssue( jiraKey = "HHH-8167" )
|
||||||
public void testAnnotatedFormWithBeanValidationNotNull() {
|
public void testAnnotatedFormWithBeanValidationNotNull() {
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.formulajoin;
|
package org.hibernate.orm.test.formulajoin;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.FetchType;
|
import jakarta.persistence.FetchType;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.mapping;
|
package org.hibernate.orm.test.jpa.mapping;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -14,9 +14,9 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import jakarta.persistence.AssociationOverride;
|
import jakarta.persistence.AssociationOverride;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
|
@ -42,17 +42,16 @@ import jakarta.persistence.Table;
|
||||||
/**
|
/**
|
||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
@Jpa(
|
||||||
|
annotatedClasses = {
|
||||||
|
NestedEmbeddableTest.Categorization.class,
|
||||||
|
NestedEmbeddableTest.Category.class,
|
||||||
|
NestedEmbeddableTest.CcmObject.class,
|
||||||
|
NestedEmbeddableTest.Domain.class
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public class NestedEmbeddableTest {
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class[] getAnnotatedClasses() {
|
|
||||||
return new Class[] {
|
|
||||||
Categorization.class,
|
|
||||||
Category.class,
|
|
||||||
CcmObject.class,
|
|
||||||
Domain.class
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test() {
|
public void test() {
|
||||||
|
@ -115,7 +114,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "CATEGORY_TITLES",
|
joinTable = @JoinTable(name = "CATEGORY_TITLES",
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}
|
@JoinColumn(name = "OBJECT_ID")
|
||||||
|
}
|
||||||
))
|
))
|
||||||
private LocalizedString title;
|
private LocalizedString title;
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "CATEGORY_DESCRIPTIONS",
|
joinTable = @JoinTable(name = "CATEGORY_DESCRIPTIONS",
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}
|
@JoinColumn(name = "OBJECT_ID")
|
||||||
|
}
|
||||||
))
|
))
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
|
@ -207,7 +208,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "DOMAIN_TITLES",
|
joinTable = @JoinTable(name = "DOMAIN_TITLES",
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}))
|
@JoinColumn(name = "OBJECT_ID")
|
||||||
|
}))
|
||||||
private LocalizedString title;
|
private LocalizedString title;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
|
@ -215,7 +217,8 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
name = "values",
|
name = "values",
|
||||||
joinTable = @JoinTable(name = "DOMAIN_DESCRIPTIONS",
|
joinTable = @JoinTable(name = "DOMAIN_DESCRIPTIONS",
|
||||||
joinColumns = {
|
joinColumns = {
|
||||||
@JoinColumn(name = "OBJECT_ID")}))
|
@JoinColumn(name = "OBJECT_ID")
|
||||||
|
}))
|
||||||
private LocalizedString description;
|
private LocalizedString description;
|
||||||
|
|
||||||
public String getDomainKey() {
|
public String getDomainKey() {
|
||||||
|
@ -261,39 +264,41 @@ public class NestedEmbeddableTest extends BaseEntityManagerFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Locale, String> getValues() {
|
public Map<Locale, String> getValues() {
|
||||||
if (values == null) {
|
if ( values == null ) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
}
|
||||||
return Collections.unmodifiableMap( values);
|
else {
|
||||||
|
return Collections.unmodifiableMap( values );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setValues(final Map<Locale, String> values) {
|
protected void setValues(final Map<Locale, String> values) {
|
||||||
if (values == null) {
|
if ( values == null ) {
|
||||||
this.values = new HashMap<>();
|
this.values = new HashMap<>();
|
||||||
} else {
|
}
|
||||||
this.values = new HashMap<>(values);
|
else {
|
||||||
|
this.values = new HashMap<>( values );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return getValue(Locale.getDefault());
|
return getValue( Locale.getDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue(final Locale locale) {
|
public String getValue(final Locale locale) {
|
||||||
return values.get(locale);
|
return values.get( locale );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addValue(final Locale locale, final String value) {
|
public void addValue(final Locale locale, final String value) {
|
||||||
values.put(locale, value);
|
values.put( locale, value );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeValue(final Locale locale) {
|
public void removeValue(final Locale locale) {
|
||||||
values.remove(locale);
|
values.remove( locale );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasValue(final Locale locale) {
|
public boolean hasValue(final Locale locale) {
|
||||||
return values.containsKey(locale);
|
return values.containsKey( locale );
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Locale> getAvailableLocales() {
|
public Set<Locale> getAvailableLocales() {
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.jpa.test.mapping;
|
package org.hibernate.orm.test.jpa.mapping;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
|
@ -4,26 +4,15 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import jakarta.persistence.Basic;
|
|
||||||
import jakarta.persistence.CollectionTable;
|
|
||||||
import jakarta.persistence.ElementCollection;
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.JoinColumn;
|
|
||||||
import jakarta.persistence.ManyToMany;
|
import jakarta.persistence.ManyToMany;
|
||||||
import jakarta.persistence.MapKeyColumn;
|
|
||||||
|
|
||||||
import org.hibernate.test.namingstrategy.Item;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Category {
|
public class Category {
|
|
@ -9,7 +9,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
<hibernate-mapping
|
<hibernate-mapping
|
||||||
package="org.hibernate.test.namingstrategy">
|
package="org.hibernate.orm.test.namingstrategy">
|
||||||
<class name="Customers">
|
<class name="Customers">
|
||||||
<id name="id" column="id" type="int"/>
|
<id name="id" column="id" type="int"/>
|
||||||
<property name="specified_column" column="specified_column"/>
|
<property name="specified_column" column="specified_column"/>
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@ -21,20 +21,21 @@ import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.ForeignKey;
|
import org.hibernate.mapping.ForeignKey;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class FullyQualifiedEntityNameNamingStrategyTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class FullyQualifiedEntityNameNamingStrategyTest {
|
||||||
private StandardServiceRegistry ssr;
|
private StandardServiceRegistry ssr;
|
||||||
private MetadataImplementor metadata;
|
private MetadataImplementor metadata;
|
||||||
|
|
||||||
@BeforeClassOnce
|
@BeforeAll
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
ssr = new StandardServiceRegistryBuilder().build();
|
ssr = new StandardServiceRegistryBuilder().build();
|
||||||
metadata = (MetadataImplementor) new MetadataSources( ssr )
|
metadata = (MetadataImplementor) new MetadataSources( ssr )
|
||||||
|
@ -46,7 +47,7 @@ public class FullyQualifiedEntityNameNamingStrategyTest extends BaseUnitTestCase
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClassOnce
|
@AfterAll
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
if ( ssr != null ) {
|
if ( ssr != null ) {
|
||||||
StandardServiceRegistryBuilder.destroy( ssr );
|
StandardServiceRegistryBuilder.destroy( ssr );
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.namingstrategy;
|
||||||
|
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.mapping.Column;
|
||||||
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Emmanuel Bernard
|
||||||
|
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||||
|
*/
|
||||||
|
public class NamingStrategyTest extends BaseSessionFactoryFunctionalTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class[] getAnnotatedClasses() {
|
||||||
|
return new Class[] {
|
||||||
|
Item.class
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String[] getOrmXmlFiles() {
|
||||||
|
return new String[] {
|
||||||
|
"org/hibernate/orm/test/namingstrategy/Customers.hbm.xml"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void applySettings(StandardServiceRegistryBuilder builder) {
|
||||||
|
builder.applySetting( AvailableSettings.IMPLICIT_NAMING_STRATEGY, TestNamingStrategy.class.getName() );
|
||||||
|
builder.applySetting( AvailableSettings.PHYSICAL_NAMING_STRATEGY, TestNamingStrategy.class.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDatabaseColumnNames() {
|
||||||
|
PersistentClass classMapping = getMetadata().getEntityBinding( Customers.class.getName() );
|
||||||
|
Column stateColumn = (Column) classMapping.getProperty( "specified_column" ).getColumnIterator().next();
|
||||||
|
assertEquals( "CN_specified_column", stateColumn.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-5848")
|
||||||
|
public void testDatabaseTableNames() {
|
||||||
|
PersistentClass classMapping = getMetadata().getEntityBinding( Item.class.getName() );
|
||||||
|
Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next();
|
||||||
|
assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() );
|
||||||
|
Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next();
|
||||||
|
assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import org.hibernate.boot.model.naming.Identifier;
|
import org.hibernate.boot.model.naming.Identifier;
|
||||||
import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource;
|
import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy;
|
package org.hibernate.orm.test.namingstrategy;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
|
@ -21,7 +21,7 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.collectionJoinTableNaming;
|
package org.hibernate.orm.test.namingstrategy.collectionJoinTableNaming;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
@ -51,18 +51,19 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||||
import org.hibernate.tool.schema.TargetType;
|
import org.hibernate.tool.schema.TargetType;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Alessandro Polverini
|
* @author Alessandro Polverini
|
||||||
*/
|
*/
|
||||||
public class CollectionJoinTableNamingTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class CollectionJoinTableNamingTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-9908" )
|
@TestForIssue( jiraKey = "HHH-9908" )
|
||||||
|
@ -165,7 +166,7 @@ public class CollectionJoinTableNamingTest extends BaseUnitTestCase {
|
||||||
Collection inputs2Mapping = metadata.getCollectionBinding( Ptx.class.getName() + ".inputs2" );
|
Collection inputs2Mapping = metadata.getCollectionBinding( Ptx.class.getName() + ".inputs2" );
|
||||||
assertEquals( "ptx_input", inputs2Mapping.getCollectionTable().getName() );
|
assertEquals( "ptx_input", inputs2Mapping.getCollectionTable().getName() );
|
||||||
|
|
||||||
assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() );
|
Assertions.assertSame( inputs1Mapping.getCollectionTable(), inputs2Mapping.getCollectionTable() );
|
||||||
|
|
||||||
// NOTE : here so that tester can more easily see the produced table. It is only dumped to stdout
|
// NOTE : here so that tester can more easily see the produced table. It is only dumped to stdout
|
||||||
new SchemaExport().create( EnumSet.of( TargetType.STDOUT ), metadata );
|
new SchemaExport().create( EnumSet.of( TargetType.STDOUT ), metadata );
|
|
@ -4,11 +4,22 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.components;
|
package org.hibernate.orm.test.namingstrategy.components;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import jakarta.persistence.Basic;
|
|
||||||
|
import org.hibernate.boot.Metadata;
|
||||||
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||||
|
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
|
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
import jakarta.persistence.Embedded;
|
import jakarta.persistence.Embedded;
|
||||||
|
@ -19,23 +30,15 @@ import jakarta.persistence.GenerationType;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
|
||||||
import org.hibernate.boot.Metadata;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.hibernate.boot.MetadataSources;
|
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
|
||||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Cai Chun
|
* @author Cai Chun
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-11826")
|
@TestForIssue(jiraKey = "HHH-11826")
|
||||||
public class ComponentNamingStrategyForJoinColumnTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class ComponentNamingStrategyForJoinColumnTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNamingComponentPath() {
|
public void testNamingComponentPath() {
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.components;
|
package org.hibernate.orm.test.namingstrategy.components;
|
||||||
|
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
@ -19,16 +19,19 @@ import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.SimpleValue;
|
import org.hibernate.mapping.SimpleValue;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.testing.orm.junit.ExtraAssertions.assertTyping;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class ComponentNamingStrategyTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class ComponentNamingStrategyTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultNamingStrategy() {
|
public void testDefaultNamingStrategy() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder().build();
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.components;
|
package org.hibernate.orm.test.namingstrategy.components;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.components;
|
package org.hibernate.orm.test.namingstrategy.components;
|
||||||
|
|
||||||
import jakarta.persistence.Embeddable;
|
import jakarta.persistence.Embeddable;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.ejb3joincolumn;
|
package org.hibernate.orm.test.namingstrategy.ejb3joincolumn;
|
||||||
|
|
||||||
import jakarta.persistence.Access;
|
import jakarta.persistence.Access;
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.ejb3joincolumn;
|
package org.hibernate.orm.test.namingstrategy.ejb3joincolumn;
|
||||||
|
|
||||||
import org.hibernate.boot.model.naming.Identifier;
|
import org.hibernate.boot.model.naming.Identifier;
|
||||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
|
import org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.ejb3joincolumn;
|
package org.hibernate.orm.test.namingstrategy.ejb3joincolumn;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -22,12 +22,12 @@ import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link org.hibernate.cfg.Ejb3JoinColumn} and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy}
|
* Tests {@link org.hibernate.cfg.Ejb3JoinColumn} and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy}
|
||||||
|
@ -36,9 +36,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
* @author Anton Wimmer
|
* @author Anton Wimmer
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class Tests extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class Tests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-9961" )
|
@TestForIssue(jiraKey = "HHH-9961")
|
||||||
public void testJpaJoinColumnPhysicalNaming() {
|
public void testJpaJoinColumnPhysicalNaming() {
|
||||||
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
final StandardServiceRegistry ssr = new StandardServiceRegistryBuilder()
|
||||||
.applySettings( Environment.getProperties() )
|
.applySettings( Environment.getProperties() )
|
||||||
|
@ -52,7 +54,7 @@ public class Tests extends BaseUnitTestCase {
|
||||||
metadataBuilder.applyPhysicalNamingStrategy( PhysicalNamingStrategyImpl.INSTANCE );
|
metadataBuilder.applyPhysicalNamingStrategy( PhysicalNamingStrategyImpl.INSTANCE );
|
||||||
|
|
||||||
final Metadata metadata = metadataBuilder.build();
|
final Metadata metadata = metadataBuilder.build();
|
||||||
( ( MetadataImplementor) metadata ).validate();
|
( (MetadataImplementor) metadata ).validate();
|
||||||
|
|
||||||
final PersistentClass languageBinding = metadata.getEntityBinding( Language.class.getName() );
|
final PersistentClass languageBinding = metadata.getEntityBinding( Language.class.getName() );
|
||||||
final Property property = languageBinding.getProperty( "fallBack" );
|
final Property property = languageBinding.getProperty( "fallBack" );
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.synchronizedTables;
|
package org.hibernate.orm.test.namingstrategy.synchronizedTables;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.namingstrategy.synchronizedTables;
|
package org.hibernate.orm.test.namingstrategy.synchronizedTables;
|
||||||
|
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.MetadataSources;
|
import org.hibernate.boot.MetadataSources;
|
||||||
|
@ -15,25 +15,26 @@ import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.orm.junit.BaseUnitTest;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class SynchronizeTableNamingTest extends BaseUnitTestCase {
|
@BaseUnitTest
|
||||||
|
public class SynchronizeTableNamingTest {
|
||||||
private StandardServiceRegistry ssr;
|
private StandardServiceRegistry ssr;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
ssr = new StandardServiceRegistryBuilder().build();
|
ssr = new StandardServiceRegistryBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void after() {
|
public void after() {
|
||||||
if ( ssr != null ) {
|
if ( ssr != null ) {
|
||||||
StandardServiceRegistryBuilder.destroy( ssr );
|
StandardServiceRegistryBuilder.destroy( ssr );
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $Id: Customer.java 5899 2005-02-24 20:08:04Z steveebersole $
|
// $Id: Customer.java 5899 2005-02-24 20:08:04Z steveebersole $
|
||||||
package org.hibernate.test.subclassfilter;
|
package org.hibernate.orm.test.subclassfilter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.subclassfilter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@DomainModel(
|
||||||
|
xmlMappings = "org/hibernate/orm/test/subclassfilter/discrim-subclass.hbm.xml"
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class DiscrimSubclassFilterTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
public void testFiltersWithSubclass(SessionFactoryScope scope) {
|
||||||
|
scope.inTransaction(
|
||||||
|
s -> {
|
||||||
|
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
|
||||||
|
|
||||||
|
prepareTestData( s );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
List results;
|
||||||
|
Iterator itr;
|
||||||
|
|
||||||
|
results = s.createQuery( "from Person" ).list();
|
||||||
|
assertEquals( 4, results.size(), "Incorrect qry result count" );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = s.createQuery( "from Employee" ).list();
|
||||||
|
assertEquals( 2, results.size(), "Incorrect qry result count" );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" )
|
||||||
|
.list() ) );
|
||||||
|
assertEquals( 4, results.size(), "Incorrect qry result count" );
|
||||||
|
itr = results.iterator();
|
||||||
|
while ( itr.hasNext() ) {
|
||||||
|
// find john
|
||||||
|
final Person p = (Person) itr.next();
|
||||||
|
if ( p.getName().equals( "John Doe" ) ) {
|
||||||
|
Employee john = (Employee) p;
|
||||||
|
assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" )
|
||||||
|
.list() ) );
|
||||||
|
assertEquals( 2, results.size(), "Incorrect qry result count" );
|
||||||
|
itr = results.iterator();
|
||||||
|
while ( itr.hasNext() ) {
|
||||||
|
// find john
|
||||||
|
final Person p = (Person) itr.next();
|
||||||
|
if ( p.getName().equals( "John Doe" ) ) {
|
||||||
|
Employee john = (Employee) p;
|
||||||
|
assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
s -> {
|
||||||
|
s.createQuery( "delete Customer where contactOwner is not null" ).executeUpdate();
|
||||||
|
s.createQuery( "delete Employee where manager is not null" ).executeUpdate();
|
||||||
|
s.createQuery( "delete Person" ).executeUpdate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
private void prepareTestData(Session s) {
|
||||||
|
Employee john = new Employee( "John Doe" );
|
||||||
|
john.setCompany( "JBoss" );
|
||||||
|
john.setDepartment( "hr" );
|
||||||
|
john.setTitle( "hr guru" );
|
||||||
|
john.setRegion( "US" );
|
||||||
|
|
||||||
|
Employee polli = new Employee( "Polli Wog" );
|
||||||
|
polli.setCompany( "JBoss" );
|
||||||
|
polli.setDepartment( "hr" );
|
||||||
|
polli.setTitle( "hr novice" );
|
||||||
|
polli.setRegion( "US" );
|
||||||
|
polli.setManager( john );
|
||||||
|
john.getMinions().add( polli );
|
||||||
|
|
||||||
|
Employee suzie = new Employee( "Suzie Q" );
|
||||||
|
suzie.setCompany( "JBoss" );
|
||||||
|
suzie.setDepartment( "hr" );
|
||||||
|
suzie.setTitle( "hr novice" );
|
||||||
|
suzie.setRegion( "EMEA" );
|
||||||
|
suzie.setManager( john );
|
||||||
|
john.getMinions().add( suzie );
|
||||||
|
|
||||||
|
Customer cust = new Customer( "John Q Public" );
|
||||||
|
cust.setCompany( "Acme" );
|
||||||
|
cust.setRegion( "US" );
|
||||||
|
cust.setContactOwner( john );
|
||||||
|
|
||||||
|
Person ups = new Person( "UPS guy" );
|
||||||
|
ups.setCompany( "UPS" );
|
||||||
|
ups.setRegion( "US" );
|
||||||
|
|
||||||
|
s.save( john );
|
||||||
|
s.save( cust );
|
||||||
|
s.save( ups );
|
||||||
|
|
||||||
|
s.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $Id: Employee.java 5899 2005-02-24 20:08:04Z steveebersole $
|
// $Id: Employee.java 5899 2005-02-24 20:08:04Z steveebersole $
|
||||||
package org.hibernate.test.subclassfilter;
|
package org.hibernate.orm.test.subclassfilter;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $Id: Person.java 5899 2005-02-24 20:08:04Z steveebersole $
|
// $Id: Person.java 5899 2005-02-24 20:08:04Z steveebersole $
|
||||||
package org.hibernate.test.subclassfilter;
|
package org.hibernate.orm.test.subclassfilter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -0,0 +1,135 @@
|
||||||
|
/*
|
||||||
|
* 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.orm.test.subclassfilter;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.Session;
|
||||||
|
|
||||||
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
@DomainModel(
|
||||||
|
xmlMappings = "org/hibernate/orm/test/subclassfilter/union-subclass.hbm.xml"
|
||||||
|
)
|
||||||
|
@SessionFactory
|
||||||
|
public class UnionSubclassFilterTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
public void testFiltersWithUnionSubclass(SessionFactoryScope scope) {
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
s -> {
|
||||||
|
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
|
||||||
|
|
||||||
|
prepareTestData( s );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
List results;
|
||||||
|
Iterator itr;
|
||||||
|
|
||||||
|
results = s.createQuery( "from Person" ).list();
|
||||||
|
assertEquals( 4, results.size(), "Incorrect qry result count" );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = s.createQuery( "from Employee" ).list();
|
||||||
|
assertEquals( 2, results.size(), "Incorrect qry result count" );
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" )
|
||||||
|
.list() ) );
|
||||||
|
assertEquals( 4, results.size(), "Incorrect qry result count" );
|
||||||
|
itr = results.iterator();
|
||||||
|
while ( itr.hasNext() ) {
|
||||||
|
// find john
|
||||||
|
final Person p = (Person) itr.next();
|
||||||
|
if ( p.getName().equals( "John Doe" ) ) {
|
||||||
|
Employee john = (Employee) p;
|
||||||
|
assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.clear();
|
||||||
|
|
||||||
|
results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" )
|
||||||
|
.list() ) );
|
||||||
|
assertEquals( 2, results.size(), "Incorrect qry result count" );
|
||||||
|
itr = results.iterator();
|
||||||
|
while ( itr.hasNext() ) {
|
||||||
|
// find john
|
||||||
|
final Person p = (Person) itr.next();
|
||||||
|
if ( p.getName().equals( "John Doe" ) ) {
|
||||||
|
Employee john = (Employee) p;
|
||||||
|
assertEquals( 1, john.getMinions().size(), "Incorrect fecthed minions count" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
scope.inTransaction(
|
||||||
|
s -> {
|
||||||
|
for ( Object entity : s.createQuery( "from Person" ).list() ) {
|
||||||
|
s.delete( entity );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "unchecked" })
|
||||||
|
private void prepareTestData(Session s) {
|
||||||
|
Employee john = new Employee( "John Doe" );
|
||||||
|
john.setCompany( "JBoss" );
|
||||||
|
john.setDepartment( "hr" );
|
||||||
|
john.setTitle( "hr guru" );
|
||||||
|
john.setRegion( "US" );
|
||||||
|
|
||||||
|
Employee polli = new Employee( "Polli Wog" );
|
||||||
|
polli.setCompany( "JBoss" );
|
||||||
|
polli.setDepartment( "hr" );
|
||||||
|
polli.setTitle( "hr novice" );
|
||||||
|
polli.setRegion( "US" );
|
||||||
|
polli.setManager( john );
|
||||||
|
john.getMinions().add( polli );
|
||||||
|
|
||||||
|
Employee suzie = new Employee( "Suzie Q" );
|
||||||
|
suzie.setCompany( "JBoss" );
|
||||||
|
suzie.setDepartment( "hr" );
|
||||||
|
suzie.setTitle( "hr novice" );
|
||||||
|
suzie.setRegion( "EMEA" );
|
||||||
|
suzie.setManager( john );
|
||||||
|
john.getMinions().add( suzie );
|
||||||
|
|
||||||
|
Customer cust = new Customer( "John Q Public" );
|
||||||
|
cust.setCompany( "Acme" );
|
||||||
|
cust.setRegion( "US" );
|
||||||
|
cust.setContactOwner( john );
|
||||||
|
|
||||||
|
Person ups = new Person( "UPS guy" );
|
||||||
|
ups.setCompany( "UPS" );
|
||||||
|
ups.setRegion( "US" );
|
||||||
|
|
||||||
|
s.save( john );
|
||||||
|
s.save( cust );
|
||||||
|
s.save( ups );
|
||||||
|
|
||||||
|
s.flush();
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,7 +9,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.subclassfilter">
|
<hibernate-mapping package="org.hibernate.orm.test.subclassfilter">
|
||||||
|
|
||||||
<class name="Person" discriminator-value="0" table="SPerson">
|
<class name="Person" discriminator-value="0" table="SPerson">
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.subclassfilter">
|
<hibernate-mapping package="org.hibernate.orm.test.subclassfilter">
|
||||||
|
|
||||||
<class name="Person" table="UPerson">
|
<class name="Person" table="UPerson">
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.tenantid;
|
package org.hibernate.orm.test.tenantid;
|
||||||
|
|
||||||
import org.hibernate.annotations.TenantId;
|
import org.hibernate.annotations.TenantId;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.tenantid;
|
package org.hibernate.orm.test.tenantid;
|
||||||
|
|
||||||
import org.hibernate.annotations.TenantId;
|
import org.hibernate.annotations.TenantId;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
* 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>.
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.tenantid;
|
package org.hibernate.orm.test.tenantid;
|
||||||
|
|
||||||
import org.hibernate.PropertyValueException;
|
import org.hibernate.PropertyValueException;
|
||||||
import org.hibernate.boot.SessionFactoryBuilder;
|
import org.hibernate.boot.SessionFactoryBuilder;
|
|
@ -1,62 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.namingstrategy;
|
|
||||||
|
|
||||||
import org.hibernate.boot.MetadataBuilder;
|
|
||||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
|
|
||||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
|
||||||
import org.hibernate.mapping.Column;
|
|
||||||
import org.hibernate.mapping.PersistentClass;
|
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Emmanuel Bernard
|
|
||||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
|
||||||
*/
|
|
||||||
public class NamingStrategyTest extends BaseNonConfigCoreFunctionalTestCase {
|
|
||||||
@Override
|
|
||||||
protected void configureMetadataBuilder(MetadataBuilder metadataBuilder) {
|
|
||||||
metadataBuilder.applyImplicitNamingStrategy( (ImplicitNamingStrategy) TestNamingStrategy.INSTANCE );
|
|
||||||
metadataBuilder.applyPhysicalNamingStrategy( (PhysicalNamingStrategy) TestNamingStrategy.INSTANCE );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
|
||||||
return new Class<?>[] {
|
|
||||||
Item.class
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getMappings() {
|
|
||||||
return new String[] {
|
|
||||||
"namingstrategy/Customers.hbm.xml"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDatabaseColumnNames() {
|
|
||||||
PersistentClass classMapping = metadata().getEntityBinding( Customers.class.getName() );
|
|
||||||
Column stateColumn = (Column) classMapping.getProperty( "specified_column" ).getColumnIterator().next();
|
|
||||||
assertEquals( "CN_specified_column", stateColumn.getName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestForIssue(jiraKey = "HHH-5848")
|
|
||||||
public void testDatabaseTableNames() {
|
|
||||||
PersistentClass classMapping = metadata().getEntityBinding( Item.class.getName() );
|
|
||||||
Column secTabColumn = (Column) classMapping.getProperty( "specialPrice" ).getColumnIterator().next();
|
|
||||||
assertEquals( "TAB_ITEMS_SEC", secTabColumn.getValue().getTable().getName() );
|
|
||||||
Column tabColumn = (Column) classMapping.getProperty( "price" ).getColumnIterator().next();
|
|
||||||
assertEquals( "TAB_ITEMS", tabColumn.getValue().getTable().getName() );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,130 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.subclassfilter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.Transaction;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase {
|
|
||||||
public final String[] getMappings() {
|
|
||||||
return new String[] { "subclassfilter/discrim-subclass.hbm.xml" };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@SuppressWarnings( {"unchecked"})
|
|
||||||
public void testFiltersWithSubclass() {
|
|
||||||
Session s = openSession();
|
|
||||||
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
|
|
||||||
Transaction t = s.beginTransaction();
|
|
||||||
|
|
||||||
prepareTestData( s );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
List results;
|
|
||||||
Iterator itr;
|
|
||||||
|
|
||||||
results = s.createQuery( "from Person" ).list();
|
|
||||||
assertEquals( "Incorrect qry result count", 4, results.size() );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = s.createQuery( "from Employee" ).list();
|
|
||||||
assertEquals( "Incorrect qry result count", 2, results.size() );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ).list() ) );
|
|
||||||
assertEquals( "Incorrect qry result count", 4, results.size() );
|
|
||||||
itr = results.iterator();
|
|
||||||
while ( itr.hasNext() ) {
|
|
||||||
// find john
|
|
||||||
final Person p = ( Person ) itr.next();
|
|
||||||
if ( p.getName().equals( "John Doe" ) ) {
|
|
||||||
Employee john = ( Employee ) p;
|
|
||||||
assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ).list() ) );
|
|
||||||
assertEquals( "Incorrect qry result count", 2, results.size() );
|
|
||||||
itr = results.iterator();
|
|
||||||
while ( itr.hasNext() ) {
|
|
||||||
// find john
|
|
||||||
final Person p = ( Person ) itr.next();
|
|
||||||
if ( p.getName().equals( "John Doe" ) ) {
|
|
||||||
Employee john = ( Employee ) p;
|
|
||||||
assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t.commit();
|
|
||||||
s.close();
|
|
||||||
|
|
||||||
s = openSession();
|
|
||||||
t = s.beginTransaction();
|
|
||||||
s.createQuery( "delete Customer where contactOwner is not null" ).executeUpdate();
|
|
||||||
s.createQuery( "delete Employee where manager is not null" ).executeUpdate();
|
|
||||||
s.createQuery( "delete Person" ).executeUpdate();
|
|
||||||
t.commit();
|
|
||||||
s.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings( {"unchecked"})
|
|
||||||
private void prepareTestData(Session s) {
|
|
||||||
Employee john = new Employee("John Doe");
|
|
||||||
john.setCompany( "JBoss" );
|
|
||||||
john.setDepartment( "hr" );
|
|
||||||
john.setTitle( "hr guru" );
|
|
||||||
john.setRegion( "US" );
|
|
||||||
|
|
||||||
Employee polli = new Employee("Polli Wog");
|
|
||||||
polli.setCompany( "JBoss" );
|
|
||||||
polli.setDepartment( "hr" );
|
|
||||||
polli.setTitle( "hr novice" );
|
|
||||||
polli.setRegion( "US" );
|
|
||||||
polli.setManager( john );
|
|
||||||
john.getMinions().add( polli );
|
|
||||||
|
|
||||||
Employee suzie = new Employee( "Suzie Q" );
|
|
||||||
suzie.setCompany( "JBoss" );
|
|
||||||
suzie.setDepartment( "hr" );
|
|
||||||
suzie.setTitle( "hr novice" );
|
|
||||||
suzie.setRegion( "EMEA" );
|
|
||||||
suzie.setManager( john );
|
|
||||||
john.getMinions().add( suzie );
|
|
||||||
|
|
||||||
Customer cust = new Customer( "John Q Public" );
|
|
||||||
cust.setCompany( "Acme" );
|
|
||||||
cust.setRegion( "US" );
|
|
||||||
cust.setContactOwner( john );
|
|
||||||
|
|
||||||
Person ups = new Person( "UPS guy" );
|
|
||||||
ups.setCompany( "UPS" );
|
|
||||||
ups.setRegion( "US" );
|
|
||||||
|
|
||||||
s.save( john );
|
|
||||||
s.save( cust );
|
|
||||||
s.save( ups );
|
|
||||||
|
|
||||||
s.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,6 +17,10 @@ import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
|
import org.hibernate.orm.test.subclassfilter.Customer;
|
||||||
|
import org.hibernate.orm.test.subclassfilter.Employee;
|
||||||
|
import org.hibernate.orm.test.subclassfilter.Person;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
|
@ -1,130 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.subclassfilter;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
|
||||||
import org.hibernate.Transaction;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class UnionSubclassFilterTest extends BaseCoreFunctionalTestCase {
|
|
||||||
public final String[] getMappings() {
|
|
||||||
return new String[] { "subclassfilter/union-subclass.hbm.xml" };
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@SuppressWarnings( {"unchecked"})
|
|
||||||
public void testFiltersWithUnionSubclass() {
|
|
||||||
Session s = openSession();
|
|
||||||
s.enableFilter( "region" ).setParameter( "userRegion", "US" );
|
|
||||||
Transaction t = s.beginTransaction();
|
|
||||||
|
|
||||||
prepareTestData( s );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
List results;
|
|
||||||
Iterator itr;
|
|
||||||
|
|
||||||
results = s.createQuery( "from Person" ).list();
|
|
||||||
assertEquals( "Incorrect qry result count", 4, results.size() );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = s.createQuery( "from Employee" ).list();
|
|
||||||
assertEquals( "Incorrect qry result count", 2, results.size() );
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = new ArrayList( new HashSet( s.createQuery( "from Person as p left join fetch p.minions" ).list() ) );
|
|
||||||
assertEquals( "Incorrect qry result count", 4, results.size() );
|
|
||||||
itr = results.iterator();
|
|
||||||
while ( itr.hasNext() ) {
|
|
||||||
// find john
|
|
||||||
final Person p = ( Person ) itr.next();
|
|
||||||
if ( p.getName().equals( "John Doe" ) ) {
|
|
||||||
Employee john = ( Employee ) p;
|
|
||||||
assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.clear();
|
|
||||||
|
|
||||||
results = new ArrayList( new HashSet( s.createQuery( "from Employee as p left join fetch p.minions" ).list() ) );
|
|
||||||
assertEquals( "Incorrect qry result count", 2, results.size() );
|
|
||||||
itr = results.iterator();
|
|
||||||
while ( itr.hasNext() ) {
|
|
||||||
// find john
|
|
||||||
final Person p = ( Person ) itr.next();
|
|
||||||
if ( p.getName().equals( "John Doe" ) ) {
|
|
||||||
Employee john = ( Employee ) p;
|
|
||||||
assertEquals( "Incorrect fecthed minions count", 1, john.getMinions().size() );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
t.commit();
|
|
||||||
s.close();
|
|
||||||
|
|
||||||
s = openSession();
|
|
||||||
t = s.beginTransaction();
|
|
||||||
for ( Object entity : s.createQuery( "from Person" ).list() ) {
|
|
||||||
s.delete( entity );
|
|
||||||
}
|
|
||||||
t.commit();
|
|
||||||
s.close();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings( {"unchecked"})
|
|
||||||
private void prepareTestData(Session s) {
|
|
||||||
Employee john = new Employee( "John Doe" );
|
|
||||||
john.setCompany( "JBoss" );
|
|
||||||
john.setDepartment( "hr" );
|
|
||||||
john.setTitle( "hr guru" );
|
|
||||||
john.setRegion( "US" );
|
|
||||||
|
|
||||||
Employee polli = new Employee( "Polli Wog" );
|
|
||||||
polli.setCompany( "JBoss" );
|
|
||||||
polli.setDepartment( "hr" );
|
|
||||||
polli.setTitle( "hr novice" );
|
|
||||||
polli.setRegion( "US" );
|
|
||||||
polli.setManager( john );
|
|
||||||
john.getMinions().add( polli );
|
|
||||||
|
|
||||||
Employee suzie = new Employee( "Suzie Q" );
|
|
||||||
suzie.setCompany( "JBoss" );
|
|
||||||
suzie.setDepartment( "hr" );
|
|
||||||
suzie.setTitle( "hr novice" );
|
|
||||||
suzie.setRegion( "EMEA" );
|
|
||||||
suzie.setManager( john );
|
|
||||||
john.getMinions().add( suzie );
|
|
||||||
|
|
||||||
Customer cust = new Customer( "John Q Public" );
|
|
||||||
cust.setCompany( "Acme" );
|
|
||||||
cust.setRegion( "US" );
|
|
||||||
cust.setContactOwner( john );
|
|
||||||
|
|
||||||
Person ups = new Person( "UPS guy" );
|
|
||||||
ups.setCompany( "UPS" );
|
|
||||||
ups.setRegion( "US" );
|
|
||||||
|
|
||||||
s.save( john );
|
|
||||||
s.save( cust );
|
|
||||||
s.save( ups );
|
|
||||||
|
|
||||||
s.flush();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -9,7 +9,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.subclassfilter">
|
<hibernate-mapping package="org.hibernate.orm.test.subclassfilter">
|
||||||
|
|
||||||
<class name="Person" table="JPerson">
|
<class name="Person" table="JPerson">
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
|
<hibernate-mapping xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd"
|
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd"
|
||||||
package="org.hibernate.test.boot.database.qualfiedTableNaming"
|
package="org.hibernate.orm.test.boot.database.qualfiedTableNaming"
|
||||||
catalog="someImplicitFileLevelCatalog" schema="someImplicitFileLevelSchema" default-access="field">
|
catalog="someImplicitFileLevelCatalog" schema="someImplicitFileLevelSchema" default-access="field">
|
||||||
<class name="DefaultCatalogAndSchemaTest$EntityWithHbmXmlImplicitFileLevelQualifiers" entity-name="EntityWithHbmXmlImplicitFileLevelQualifiers">
|
<class name="DefaultCatalogAndSchemaTest$EntityWithHbmXmlImplicitFileLevelQualifiers" entity-name="EntityWithHbmXmlImplicitFileLevelQualifiers">
|
||||||
<id name="id" />
|
<id name="id" />
|
|
@ -10,7 +10,7 @@
|
||||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm
|
||||||
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
|
http://xmlns.jcp.org/xml/ns/persistence/orm_2_1.xsd"
|
||||||
version="2.1">
|
version="2.1">
|
||||||
<package>org.hibernate.test.boot.database.qualfiedTableNaming</package>
|
<package>org.hibernate.orm.test.boot.database.qualfiedTableNaming</package>
|
||||||
<schema>someImplicitFileLevelSchema</schema>
|
<schema>someImplicitFileLevelSchema</schema>
|
||||||
<catalog>someImplicitFileLevelCatalog</catalog>
|
<catalog>someImplicitFileLevelCatalog</catalog>
|
||||||
<entity class="DefaultCatalogAndSchemaTest$EntityWithOrmXmlImplicitFileLevelQualifiers" name="EntityWithOrmXmlImplicitFileLevelQualifiers"
|
<entity class="DefaultCatalogAndSchemaTest$EntityWithOrmXmlImplicitFileLevelQualifiers" name="EntityWithOrmXmlImplicitFileLevelQualifiers"
|
|
@ -9,7 +9,7 @@
|
||||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.namingstrategy.synchronizedTables">
|
<hibernate-mapping package="org.hibernate.orm.test.namingstrategy.synchronizedTables">
|
||||||
|
|
||||||
<class name="DynamicEntity">
|
<class name="DynamicEntity">
|
||||||
<synchronize table="table_a"/>
|
<synchronize table="table_a"/>
|
||||||
|
|
Loading…
Reference in New Issue