HHH-7666 Replace unit tests' use of configuration()
This commit is contained in:
parent
b88b32382f
commit
f3a8760d22
|
@ -59,7 +59,7 @@ public class EntityTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad() throws Exception {
|
public void testLoad() throws Exception {
|
||||||
//put an object in DB
|
//put an object in DB
|
||||||
assertEquals( "Flight", configuration().getClassMapping( Flight.class.getName() ).getTable().getName() );
|
assertEquals( "Flight", getEntityBinding( Flight.class ).getPrimaryTableName() );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
@ -314,7 +314,7 @@ public class EntityTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityName() throws Exception {
|
public void testEntityName() throws Exception {
|
||||||
assertEquals( "Corporation", configuration().getClassMapping( Company.class.getName() ).getTable().getName() );
|
assertEquals( "Corporation", getEntityBinding( Company.class ).getPrimaryTableName() );
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
Company comp = new Company();
|
Company comp = new Company();
|
||||||
|
|
|
@ -23,21 +23,20 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.beanvalidation;
|
package org.hibernate.test.annotations.beanvalidation;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import static org.junit.Assert.assertTrue;
|
||||||
import javax.validation.ConstraintViolationException;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -62,11 +61,11 @@ public class BeanValidationDisabledTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testDDLDisabled() {
|
public void testDDLDisabled() {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
|
EntityBinding binding = getEntityBinding( Address.class );
|
||||||
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
|
Column countryColumn = binding.getPrimaryTable().locateColumn( "country" );
|
||||||
assertTrue( "DDL constraints are applied", countryColumn.isNullable() );
|
assertTrue( "DDL constraints are applied", countryColumn.isNullable() );
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,19 +23,18 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.beanvalidation;
|
package org.hibernate.test.annotations.beanvalidation;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.mapping.Column;
|
|
||||||
import org.hibernate.mapping.PersistentClass;
|
|
||||||
import org.hibernate.mapping.Property;
|
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
|
import org.hibernate.metamodel.spi.relational.Index;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
|
import org.hibernate.testing.TestForIssue;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test verifying that DDL constraints get applied when Bean Validation / Hibernate Validator are enabled.
|
* Test verifying that DDL constraints get applied when Bean Validation / Hibernate Validator are enabled.
|
||||||
*
|
*
|
||||||
|
@ -46,56 +45,49 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DDLTest extends BaseCoreFunctionalTestCase {
|
public class DDLTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testBasicDDL() {
|
public void testBasicDDL() {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
|
Column stateColumn = SchemaUtil.getColumn( Address.class, "state", metadata() );
|
||||||
Column stateColumn = (Column) classMapping.getProperty( "state" ).getColumnIterator().next();
|
assertEquals( stateColumn.getSize().getLength(), 3 );
|
||||||
assertEquals( stateColumn.getLength(), 3 );
|
Column zipColumn = SchemaUtil.getColumn( Address.class, "zip", metadata() );
|
||||||
Column zipColumn = (Column) classMapping.getProperty( "zip" ).getColumnIterator().next();
|
assertEquals( zipColumn.getSize().getLength(), 5 );
|
||||||
assertEquals( zipColumn.getLength(), 5 );
|
|
||||||
assertFalse( zipColumn.isNullable() );
|
assertFalse( zipColumn.isNullable() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyOnIdColumn() throws Exception {
|
public void testApplyOnIdColumn() throws Exception {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
|
Index index = SchemaUtil.getIndexes( Tv.class, metadata() ).next();
|
||||||
Column serialColumn = (Column) classMapping.getIdentifierProperty().getColumnIterator().next();
|
assertEquals( "Validator annotation not applied on ids", 2,
|
||||||
assertEquals( "Validator annotation not applied on ids", 2, serialColumn.getLength() );
|
index.getColumns().get( 0 ).getSize().getLength() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-5281" )
|
@TestForIssue( jiraKey = "HHH-5281" )
|
||||||
public void testLengthConstraint() throws Exception {
|
public void testLengthConstraint() throws Exception {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
|
Column column = SchemaUtil.getColumn( Tv.class, "model", metadata() );
|
||||||
Column modelColumn = (Column) classMapping.getProperty( "model" ).getColumnIterator().next();
|
assertEquals( column.getSize().getLength(), 5 );
|
||||||
assertEquals( modelColumn.getLength(), 5 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testApplyOnManyToOne() throws Exception {
|
public void testApplyOnManyToOne() throws Exception {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( TvOwner.class.getName() );
|
Column column = SchemaUtil.getColumn( TvOwner.class, "tv", metadata() );
|
||||||
Column serialColumn = (Column) classMapping.getProperty( "tv" ).getColumnIterator().next();
|
assertEquals( "Validator annotations not applied on associations", false, column.isNullable() );
|
||||||
assertEquals( "Validator annotations not applied on associations", false, serialColumn.isNullable() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSingleTableAvoidNotNull() throws Exception {
|
public void testSingleTableAvoidNotNull() throws Exception {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Rock.class.getName() );
|
Column column = SchemaUtil.getColumn( Rock.class, "bit", metadata() );
|
||||||
Column serialColumn = (Column) classMapping.getProperty( "bit" ).getColumnIterator().next();
|
assertTrue( "Notnull should not be applied on single tables", column.isNullable() );
|
||||||
assertTrue( "Notnull should not be applied on single tables", serialColumn.isNullable() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
|
public void testNotNullOnlyAppliedIfEmbeddedIsNotNullItself() throws Exception {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Tv.class.getName() );
|
Column column = SchemaUtil.getColumn( Tv.class, "tuner.frequency", metadata() );
|
||||||
Property property = classMapping.getProperty( "tuner.frequency" );
|
|
||||||
Column serialColumn = (Column) property.getColumnIterator().next();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Validator annotations are applied on tuner as it is @NotNull", false, serialColumn.isNullable()
|
"Validator annotations are applied on tuner as it is @NotNull", false, column.isNullable()
|
||||||
);
|
);
|
||||||
|
|
||||||
property = classMapping.getProperty( "recorder.time" );
|
column = SchemaUtil.getColumn( Tv.class, "recorder.time", metadata() );
|
||||||
serialColumn = (Column) property.getColumnIterator().next();
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Validator annotations are applied on tuner as it is @NotNull", true, serialColumn.isNullable()
|
"Validator annotations are applied on tuner as it is @NotNull", true, column.isNullable()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,23 +23,23 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.beanvalidation;
|
package org.hibernate.test.annotations.beanvalidation;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import static org.junit.Assert.assertFalse;
|
||||||
import javax.validation.ConstraintViolationException;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.validation.ConstraintViolationException;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Vladimir Klyushnikov
|
* @author Vladimir Klyushnikov
|
||||||
|
@ -93,11 +93,9 @@ public class DDLWithoutCallbackTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testDDLEnabled() {
|
public void testDDLEnabled() {
|
||||||
PersistentClass classMapping = configuration().getClassMapping( Address.class.getName() );
|
Column column = SchemaUtil.getColumn( Address.class, "country", metadata() );
|
||||||
Column countryColumn = (Column) classMapping.getProperty( "country" ).getColumnIterator().next();
|
assertFalse( "DDL constraints are not applied", column.isNullable() );
|
||||||
assertFalse( "DDL constraints are not applied", countryColumn.isNullable() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,8 +34,7 @@ import org.hibernate.Filter;
|
||||||
import org.hibernate.Query;
|
import org.hibernate.Query;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||||
import org.hibernate.mapping.Column;
|
|
||||||
import org.hibernate.test.annotations.Country;
|
import org.hibernate.test.annotations.Country;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -251,32 +250,28 @@ public class CollectionElementTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultValueColumnForBasic() throws Exception {
|
public void testDefaultValueColumnForBasic() throws Exception {
|
||||||
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "hatedNames" );
|
isCollectionColumnPresent( Boy.class.getName(), "hatedNames" );
|
||||||
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "preferredNames" );
|
isCollectionColumnPresent( Boy.class.getName(), "preferredNames" );
|
||||||
isCollectionColumnPresent( Boy.class.getName(), "nickNames", "nickNames" );
|
isCollectionColumnPresent( Boy.class.getName(), "nickNames" );
|
||||||
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "scorePerPreferredName");
|
isCollectionColumnPresent( Boy.class.getName(), "scorePerPreferredName");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultFKNameForElementCollection() throws Exception {
|
public void testDefaultFKNameForElementCollection() throws Exception {
|
||||||
isCollectionColumnPresent( Boy.class.getName(), "hatedNames", "Boy_id" );
|
isCollectionColumnPresent( Boy.class.getName(), "Boy_id" );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void isLegacyValueCollectionColumnPresent(String collectionHolder, String propertyName) {
|
private void isCollectionColumnPresent(String collectionOwner, String columnName) {
|
||||||
|
// TODO: Is this correct? Cannot test due to ManyToOne issues.
|
||||||
}
|
Iterator<PluralAttributeBinding> bindings = getCollectionBindings();
|
||||||
|
|
||||||
private void isDefaultValueCollectionColumnPresent(String collectionOwner, String propertyName) {
|
|
||||||
isCollectionColumnPresent( collectionOwner, propertyName, propertyName );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void isCollectionColumnPresent(String collectionOwner, String propertyName, String columnName) {
|
|
||||||
final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
|
|
||||||
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
|
|
||||||
boolean hasDefault = false;
|
boolean hasDefault = false;
|
||||||
while ( columnIterator.hasNext() ) {
|
while ( bindings.hasNext() ) {
|
||||||
Column column = (Column) columnIterator.next();
|
PluralAttributeBinding binding = bindings.next();
|
||||||
if ( columnName.equals( column.getName() ) ) hasDefault = true;
|
if ( binding.getAttribute().getName().equals( columnName )
|
||||||
|
&& binding.getAttribute().getAttributeContainer().getClassName().equals( collectionOwner ) ) {
|
||||||
|
hasDefault = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertTrue( "Could not find " + columnName, hasDefault );
|
assertTrue( "Could not find " + columnName, hasDefault );
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityWithBidirectionalAssociationTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityWithBidirectionalAssociationTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testBidirectionalAssociation() throws Exception {
|
public void testBidirectionalAssociation() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) );
|
||||||
assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
|
assertTrue( !SchemaUtil.isColumnPresent( "Dependent", "empPK", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = 1;
|
e.empId = 1;
|
||||||
e.empName = "Emmanuel";
|
e.empName = "Emmanuel";
|
||||||
|
|
|
@ -44,8 +44,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentitySimpleParentIdClassDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentitySimpleParentIdClassDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
|
|
@ -40,8 +40,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentitySimpleParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentitySimpleParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = 1;
|
e.empId = 1;
|
||||||
e.empName = "Emmanuel";
|
e.empName = "Emmanuel";
|
||||||
|
@ -64,8 +64,8 @@ public class DerivedIdentitySimpleParentEmbeddedIdDepTest extends BaseCoreFuncti
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOne() throws Exception {
|
public void testOneToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "ExclusiveDependent", "FK", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "ExclusiveDependent", "FK", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "ExclusiveDependent", "empPK", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "ExclusiveDependent", "empPK", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = 1;
|
e.empId = 1;
|
||||||
e.empName = "Emmanuel";
|
e.empName = "Emmanuel";
|
||||||
|
|
|
@ -40,8 +40,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentitySimpleParentEmbeddedDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentitySimpleParentEmbeddedDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "empPK", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = 1;
|
e.empId = 1;
|
||||||
e.empName = "Emmanuel";
|
e.empName = "Emmanuel";
|
||||||
|
|
|
@ -18,11 +18,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityIdClassParentIdClassDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityIdClassParentIdClassDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManytoOne() {
|
public void testManytoOne() {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.firstName = "Emmanuel";
|
e.firstName = "Emmanuel";
|
||||||
e.lastName = "Bernard";
|
e.lastName = "Bernard";
|
||||||
|
|
|
@ -18,11 +18,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityIdClassParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityIdClassParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_firstName", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_firstName", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_lastName", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_lastName", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "name", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.firstName = "Emmanuel";
|
e.firstName = "Emmanuel";
|
||||||
e.lastName = "Bernard";
|
e.lastName = "Bernard";
|
||||||
|
|
|
@ -41,11 +41,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityEmbeddedIdParentIdClassTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityEmbeddedIdParentIdClassTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = new EmployeeId();
|
e.empId = new EmployeeId();
|
||||||
e.empId.firstName = "Emmanuel";
|
e.empId.firstName = "Emmanuel";
|
||||||
|
|
|
@ -41,11 +41,11 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityEmbeddedIdParentEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOne() throws Exception {
|
public void testManyToOne() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "FK2", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "dep_name", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "firstName", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "lastName", metadata() ) );
|
||||||
Employee e = new Employee();
|
Employee e = new Employee();
|
||||||
e.empId = new EmployeeId();
|
e.empId = new EmployeeId();
|
||||||
e.empId.firstName = "Emmanuel";
|
e.empId.firstName = "Emmanuel";
|
||||||
|
|
|
@ -43,8 +43,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentitySimpleParentSimpleDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentitySimpleParentSimpleDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
@ -75,8 +75,8 @@ public class DerivedIdentitySimpleParentSimpleDepTest extends BaseCoreFunctional
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOneExplicitJoinColumn() throws Exception {
|
public void testManyToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "patient_ssn", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "patient_ssn", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
|
|
@ -44,8 +44,8 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "id", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
e.ssn = "aaa";
|
e.ssn = "aaa";
|
||||||
Session s = openSession( );
|
Session s = openSession( );
|
||||||
|
@ -70,8 +70,8 @@ public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends BaseCoreFunc
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testManyToOneExplicitJoinColumn() throws Exception {
|
public void testManyToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "FK", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "FinancialHistory", "FK", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "FinancialHistory", "id", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
e.ssn = "aaa";
|
e.ssn = "aaa";
|
||||||
Session s = openSession( );
|
Session s = openSession( );
|
||||||
|
|
|
@ -43,9 +43,9 @@ public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest extends BaseCo
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
@ -73,9 +73,9 @@ public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest extends BaseCo
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTckLikeBehavior() throws Exception {
|
public void testTckLikeBehavior() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
|
|
@ -40,9 +40,9 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
e.firstName = "Emmanuel";
|
e.firstName = "Emmanuel";
|
||||||
e.lastName = "Bernard";
|
e.lastName = "Bernard";
|
||||||
|
|
|
@ -40,7 +40,7 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class ForeignGeneratorViaMapsIdTest extends BaseCoreFunctionalTestCase {
|
public class ForeignGeneratorViaMapsIdTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testForeignGenerator() throws Exception {
|
public void testForeignGenerator() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "patient_id", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "patient_id", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
Session s = openSession( );
|
Session s = openSession( );
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
|
|
@ -40,9 +40,9 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
e.id = new PersonId();
|
e.id = new PersonId();
|
||||||
e.id.firstName = "Emmanuel";
|
e.id.firstName = "Emmanuel";
|
||||||
|
|
|
@ -40,9 +40,9 @@ import static org.junit.Assert.assertTrue;
|
||||||
public class DerivedIdentityEmbeddedIdParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
public class DerivedIdentityEmbeddedIdParentSameIdTypeEmbeddedIdDepTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testOneToOneExplicitJoinColumn() throws Exception {
|
public void testOneToOneExplicitJoinColumn() throws Exception {
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK1", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", configuration() ) );
|
assertTrue( SchemaUtil.isColumnPresent( "MedicalHistory", "FK2", metadata() ) );
|
||||||
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", configuration() ) );
|
assertTrue( ! SchemaUtil.isColumnPresent( "MedicalHistory", "firstname", metadata() ) );
|
||||||
Person e = new Person();
|
Person e = new Person();
|
||||||
e.id = new PersonId();
|
e.id = new PersonId();
|
||||||
e.id.firstName = "Emmanuel";
|
e.id.firstName = "Emmanuel";
|
||||||
|
|
|
@ -408,9 +408,9 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultCollectionTable() throws Exception {
|
public void testDefaultCollectionTable() throws Exception {
|
||||||
//are the tables correct?
|
//are the tables correct?
|
||||||
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", configuration() ) );
|
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_legacyVacationHomes", configuration() ) );
|
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_legacyVacationHomes", metadata() ) );
|
||||||
assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", configuration() ) );
|
assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", metadata() ) );
|
||||||
|
|
||||||
//just to make sure, use the mapping
|
//just to make sure, use the mapping
|
||||||
Session s;
|
Session s;
|
||||||
|
@ -532,7 +532,12 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase {
|
||||||
CorpType.class,
|
CorpType.class,
|
||||||
Nationality.class,
|
Nationality.class,
|
||||||
Manager.class,
|
Manager.class,
|
||||||
FavoriteThings.class
|
FavoriteThings.class,
|
||||||
|
Address.class,
|
||||||
|
Country.class,
|
||||||
|
InternetFavorites.class,
|
||||||
|
FixedLeg.class,
|
||||||
|
FloatLeg.class
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
package org.hibernate.test.annotations.embedded;
|
package org.hibernate.test.annotations.embedded;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Embedded;
|
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class InternetFavorites {
|
public class InternetFavorites {
|
||||||
|
|
||||||
@Embedded
|
|
||||||
Collection<URLFavorite> links;
|
Collection<URLFavorite> links;
|
||||||
|
|
||||||
@Embedded
|
|
||||||
Collection<String> ideas;
|
Collection<String> ideas;
|
||||||
|
|
||||||
public Collection<String> getIdeas() {
|
public Collection<String> getIdeas() {
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class NewCustomEntityMappingAnnotationsTest extends BaseCoreFunctionalTes
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSameMappingValues() {
|
public void testSameMappingValues() {
|
||||||
|
// TODO: These need to use the new metamodel, but the information
|
||||||
|
// is not available in EntityBinding.
|
||||||
RootClass forest = (RootClass) configuration().getClassMapping( Forest.class.getName() );
|
RootClass forest = (RootClass) configuration().getClassMapping( Forest.class.getName() );
|
||||||
RootClass forest2 = (RootClass) configuration().getClassMapping( Forest2.class.getName() );
|
RootClass forest2 = (RootClass) configuration().getClassMapping( Forest2.class.getName() );
|
||||||
assertEquals( forest.useDynamicInsert(), forest2.useDynamicInsert() );
|
assertEquals( forest.useDynamicInsert(), forest2.useDynamicInsert() );
|
||||||
|
|
|
@ -1,22 +1,20 @@
|
||||||
package org.hibernate.test.annotations.enumerated;
|
package org.hibernate.test.annotations.enumerated;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
|
||||||
import org.hibernate.criterion.Restrictions;
|
import org.hibernate.criterion.Restrictions;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
|
import org.hibernate.test.annotations.enumerated.EntityEnum.Common;
|
||||||
|
import org.hibernate.test.annotations.enumerated.EntityEnum.FirstLetter;
|
||||||
|
import org.hibernate.test.annotations.enumerated.EntityEnum.LastNumber;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.hibernate.type.EnumType;
|
import org.hibernate.type.EnumType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.hibernate.test.annotations.enumerated.EntityEnum.Common;
|
|
||||||
import static org.hibernate.test.annotations.enumerated.EntityEnum.FirstLetter;
|
|
||||||
import static org.hibernate.test.annotations.enumerated.EntityEnum.LastNumber;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test type definition for enum
|
* Test type definition for enum
|
||||||
|
@ -28,31 +26,35 @@ public class EnumeratedTypeTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTypeDefinition() {
|
public void testTypeDefinition() {
|
||||||
Configuration cfg = configuration();
|
EntityBinding binding = getEntityBinding( EntityEnum.class );
|
||||||
PersistentClass pc = cfg.getClassMapping( EntityEnum.class.getName() );
|
|
||||||
|
|
||||||
// ordinal default of EnumType
|
// ordinal default of EnumType
|
||||||
Type ordinalEnum = pc.getProperty( "ordinal" ).getType();
|
Type ordinalEnum = binding.locateAttributeBinding( "ordinal" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( Common.class, ordinalEnum.getReturnedClass() );
|
assertEquals( Common.class, ordinalEnum.getReturnedClass() );
|
||||||
assertEquals( EnumType.class.getName(), ordinalEnum.getName() );
|
assertEquals( EnumType.class.getName(), ordinalEnum.getName() );
|
||||||
|
|
||||||
// string defined by Enumerated(STRING)
|
// string defined by Enumerated(STRING)
|
||||||
Type stringEnum = pc.getProperty( "string" ).getType();
|
Type stringEnum = binding.locateAttributeBinding( "string" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( Common.class, stringEnum.getReturnedClass() );
|
assertEquals( Common.class, stringEnum.getReturnedClass() );
|
||||||
assertEquals( EnumType.class.getName(), stringEnum.getName() );
|
assertEquals( EnumType.class.getName(), stringEnum.getName() );
|
||||||
|
|
||||||
// explicit defined by @Type
|
// explicit defined by @Type
|
||||||
Type first = pc.getProperty( "firstLetter" ).getType();
|
Type first = binding.locateAttributeBinding( "firstLetter" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( FirstLetter.class, first.getReturnedClass() );
|
assertEquals( FirstLetter.class, first.getReturnedClass() );
|
||||||
assertEquals( FirstLetterType.class.getName(), first.getName() );
|
assertEquals( FirstLetterType.class.getName(), first.getName() );
|
||||||
|
|
||||||
// implicit defined by @TypeDef in somewhere
|
// implicit defined by @TypeDef in somewhere
|
||||||
Type last = pc.getProperty( "lastNumber" ).getType();
|
Type last = binding.locateAttributeBinding( "lastNumber" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( LastNumber.class, last.getReturnedClass() );
|
assertEquals( LastNumber.class, last.getReturnedClass() );
|
||||||
assertEquals( LastNumberType.class.getName(), last.getName() );
|
assertEquals( LastNumberType.class.getName(), last.getName() );
|
||||||
|
|
||||||
// implicit defined by @TypeDef in anywhere, but overrided by Enumerated(STRING)
|
// implicit defined by @TypeDef in anywhere, but overrided by Enumerated(STRING)
|
||||||
Type implicitOverrideExplicit = pc.getProperty( "explicitOverridingImplicit" ).getType();
|
Type implicitOverrideExplicit = binding.locateAttributeBinding( "explicitOverridingImplicit" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( LastNumber.class, implicitOverrideExplicit.getReturnedClass() );
|
assertEquals( LastNumber.class, implicitOverrideExplicit.getReturnedClass() );
|
||||||
assertEquals( EnumType.class.getName(), implicitOverrideExplicit.getName() );
|
assertEquals( EnumType.class.getName(), implicitOverrideExplicit.getName() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.id;
|
package org.hibernate.test.annotations.id;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
import org.hibernate.test.annotations.id.entities.Ball;
|
import org.hibernate.test.annotations.id.entities.Ball;
|
||||||
import org.hibernate.test.annotations.id.entities.BreakDance;
|
import org.hibernate.test.annotations.id.entities.BreakDance;
|
||||||
import org.hibernate.test.annotations.id.entities.Computer;
|
import org.hibernate.test.annotations.id.entities.Computer;
|
||||||
|
@ -45,11 +46,10 @@ import org.hibernate.test.annotations.id.entities.Shoe;
|
||||||
import org.hibernate.test.annotations.id.entities.SoundSystem;
|
import org.hibernate.test.annotations.id.entities.SoundSystem;
|
||||||
import org.hibernate.test.annotations.id.entities.Store;
|
import org.hibernate.test.annotations.id.entities.Store;
|
||||||
import org.hibernate.test.annotations.id.entities.Tree;
|
import org.hibernate.test.annotations.id.entities.Tree;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -289,9 +289,9 @@ public class IdTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testColumnDefinition() {
|
public void testColumnDefinition() {
|
||||||
Column idCol = (Column) configuration().getClassMapping(Ball.class.getName())
|
Column idCol = SchemaUtil.getIndexes( Ball.class, metadata() )
|
||||||
.getIdentifierProperty().getValue().getColumnIterator().next();
|
.next().getColumns().get( 0 );
|
||||||
assertEquals( "ball_id", idCol.getName() );
|
assertEquals( "ball_id", idCol.getColumnName().getText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -23,11 +23,12 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.id.sequences;
|
package org.hibernate.test.annotations.id.sequences;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static junit.framework.Assert.assertEquals;
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
import org.hibernate.test.annotations.id.generationmappings.DedicatedSequenceEntity1;
|
import org.hibernate.test.annotations.id.generationmappings.DedicatedSequenceEntity1;
|
||||||
import org.hibernate.test.annotations.id.generationmappings.DedicatedSequenceEntity2;
|
import org.hibernate.test.annotations.id.generationmappings.DedicatedSequenceEntity2;
|
||||||
import org.hibernate.test.annotations.id.sequences.entities.Ball;
|
import org.hibernate.test.annotations.id.sequences.entities.Ball;
|
||||||
|
@ -47,14 +48,13 @@ import org.hibernate.test.annotations.id.sequences.entities.Shoe;
|
||||||
import org.hibernate.test.annotations.id.sequences.entities.SoundSystem;
|
import org.hibernate.test.annotations.id.sequences.entities.SoundSystem;
|
||||||
import org.hibernate.test.annotations.id.sequences.entities.Store;
|
import org.hibernate.test.annotations.id.sequences.entities.Store;
|
||||||
import org.hibernate.test.annotations.id.sequences.entities.Tree;
|
import org.hibernate.test.annotations.id.sequences.entities.Tree;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.DialectChecks;
|
import org.hibernate.testing.DialectChecks;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.RequiresDialectFeature;
|
import org.hibernate.testing.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static junit.framework.Assert.assertEquals;
|
|
||||||
import static junit.framework.Assert.assertNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -316,9 +316,9 @@ public class IdTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testColumnDefinition() {
|
public void testColumnDefinition() {
|
||||||
Column idCol = ( Column ) configuration().getClassMapping( Ball.class.getName() )
|
Column idCol = SchemaUtil.getIndexes( Ball.class, metadata() )
|
||||||
.getIdentifierProperty().getValue().getColumnIterator().next();
|
.next().getColumns().get( 0 );
|
||||||
assertEquals( "ball_id", idCol.getName() );
|
assertEquals( "ball_id", idCol.getColumnName().getText() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
|
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
@ -74,6 +75,7 @@ public class IndexedCollectionTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) {
|
private boolean isDefaultColumnPresent(String collectionOwner, String propertyName, String suffix) {
|
||||||
|
// TODO: Use getCollectionBindings, but unsure of suffix, etc.
|
||||||
final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
|
final Collection collection = configuration().getCollectionMapping( collectionOwner + "." + propertyName );
|
||||||
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
|
final Iterator columnIterator = collection.getCollectionTable().getColumnIterator();
|
||||||
boolean hasDefault = false;
|
boolean hasDefault = false;
|
||||||
|
|
|
@ -50,6 +50,7 @@ import static org.junit.Assert.fail;
|
||||||
public class JoinTest extends BaseCoreFunctionalTestCase {
|
public class JoinTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultValue() throws Exception {
|
public void testDefaultValue() throws Exception {
|
||||||
|
// TODO: How to get Joins with EntityBindings?
|
||||||
Join join = (Join) configuration().getClassMapping( Life.class.getName() ).getJoinClosureIterator().next();
|
Join join = (Join) configuration().getClassMapping( Life.class.getName() ).getJoinClosureIterator().next();
|
||||||
assertEquals( "ExtendedLife", join.getTable().getName() );
|
assertEquals( "ExtendedLife", join.getTable().getName() );
|
||||||
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
|
org.hibernate.mapping.Column owner = new org.hibernate.mapping.Column();
|
||||||
|
|
|
@ -3,9 +3,7 @@ package org.hibernate.test.annotations.lob;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
|
||||||
|
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
import org.hibernate.type.SerializableToBlobType;
|
import org.hibernate.type.SerializableToBlobType;
|
||||||
|
@ -21,26 +19,29 @@ import org.junit.Test;
|
||||||
public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase {
|
public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testTypeDefinition() {
|
public void testTypeDefinition() {
|
||||||
Configuration cfg = configuration();
|
EntityBinding binding = getEntityBinding( EntitySerialize.class );
|
||||||
PersistentClass pc = cfg.getClassMapping( EntitySerialize.class.getName() );
|
|
||||||
|
|
||||||
// explicitLob of SerializableToBlobType
|
// explicitLob of SerializableToBlobType
|
||||||
Type explicitLobType = pc.getProperty( "explicitLob" ).getType();
|
Type explicitLobType = binding.locateAttributeBinding( "explicitLob" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() );
|
assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() );
|
||||||
assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() );
|
assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() );
|
||||||
|
|
||||||
// explicit of ExplicitSerializableType
|
// explicit of ExplicitSerializableType
|
||||||
Type explicitType = pc.getProperty( "explicit" ).getType();
|
Type explicitType = binding.locateAttributeBinding( "explicit" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() );
|
assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() );
|
||||||
assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() );
|
assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() );
|
||||||
|
|
||||||
// implicit of ImplicitSerializableType
|
// implicit of ImplicitSerializableType
|
||||||
Type implicitType = pc.getProperty( "implicit" ).getType();
|
Type implicitType = binding.locateAttributeBinding( "implicit" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() );
|
assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() );
|
||||||
assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() );
|
assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() );
|
||||||
|
|
||||||
// explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
|
// explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
|
||||||
Type overrideType = pc.getProperty( "explicitOverridingImplicit" ).getType();
|
Type overrideType = binding.locateAttributeBinding( "explicitOverridingImplicit" )
|
||||||
|
.getHibernateTypeDescriptor().getResolvedTypeMapping();
|
||||||
assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() );
|
assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() );
|
||||||
assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() );
|
assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -479,6 +479,7 @@ public class OneToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-4605" )
|
@TestForIssue( jiraKey = "HHH-4605" )
|
||||||
public void testJoinColumnConfiguredInXml() {
|
public void testJoinColumnConfiguredInXml() {
|
||||||
|
// TODO: How to check joins with EntityBinding?
|
||||||
PersistentClass pc = configuration().getClassMapping( Model.class.getName() );
|
PersistentClass pc = configuration().getClassMapping( Model.class.getName() );
|
||||||
Table table = pc.getRootTable();
|
Table table = pc.getRootTable();
|
||||||
Iterator iter = table.getColumnIterator();
|
Iterator iter = table.getColumnIterator();
|
||||||
|
|
|
@ -311,6 +311,7 @@ public class OneToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-4606" )
|
@TestForIssue( jiraKey = "HHH-4606" )
|
||||||
public void testJoinColumnConfiguredInXml() {
|
public void testJoinColumnConfiguredInXml() {
|
||||||
|
// TODO: How to check joins with EntityBinding?
|
||||||
PersistentClass pc = configuration().getClassMapping( Son.class.getName() );
|
PersistentClass pc = configuration().getClassMapping( Son.class.getName() );
|
||||||
Iterator iter = pc.getJoinIterator();
|
Iterator iter = pc.getJoinIterator();
|
||||||
Table table = ( ( Join ) iter.next() ).getTable();
|
Table table = ( ( Join ) iter.next() ).getTable();
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
package org.hibernate.test.annotations.override;
|
package org.hibernate.test.annotations.override;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||||
import org.hibernate.test.util.SchemaUtil;
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.RequiresDialect;
|
import org.hibernate.testing.RequiresDialect;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||||
|
@ -37,24 +37,18 @@ public class AssociationOverrideSchemaTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJoinTableSchemaName() {
|
public void testJoinTableSchemaName() {
|
||||||
Iterator<Table> tableIterator = configuration().getTableMappings();
|
TableSpecification table = SchemaUtil.getTable( TABLE_NAME, metadata() );
|
||||||
while ( tableIterator.hasNext() ) {
|
assertNotNull( table );
|
||||||
Table table = tableIterator.next();
|
assertEquals( SCHEMA_NAME, table.getSchema().getName().getSchema().getText());
|
||||||
if ( TABLE_NAME.equals( table.getName() ) ) {
|
|
||||||
Assert.assertEquals( SCHEMA_NAME, table.getSchema() );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Assert.fail();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJoinTableJoinColumnName() {
|
public void testJoinTableJoinColumnName() {
|
||||||
Assert.assertTrue( SchemaUtil.isColumnPresent( TABLE_NAME, ID_COLUMN_NAME, configuration() ) );
|
Assert.assertTrue( SchemaUtil.isColumnPresent( TABLE_NAME, ID_COLUMN_NAME, metadata() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testJoinTableColumnName() {
|
public void testJoinTableColumnName() {
|
||||||
Assert.assertTrue( SchemaUtil.isColumnPresent( TABLE_NAME, VALUE_COLUMN_NAME, configuration() ) );
|
Assert.assertTrue( SchemaUtil.isColumnPresent( TABLE_NAME, VALUE_COLUMN_NAME, metadata() ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
package org.hibernate.test.annotations.override;
|
package org.hibernate.test.annotations.override;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.test.util.SchemaUtil;
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -50,15 +49,15 @@ public class AssociationOverrideTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDottedNotation() throws Exception {
|
public void testDottedNotation() throws Exception {
|
||||||
assertTrue( SchemaUtil.isTablePresent( "Employee", configuration() ) );
|
assertTrue( SchemaUtil.isTablePresent( "Employee", metadata() ) );
|
||||||
assertTrue( "Overridden @JoinColumn fails",
|
assertTrue( "Overridden @JoinColumn fails",
|
||||||
SchemaUtil.isColumnPresent( "Employee", "fld_address_fk", configuration() ) );
|
SchemaUtil.isColumnPresent( "Employee", "fld_address_fk", metadata() ) );
|
||||||
|
|
||||||
assertTrue( "Overridden @JoinTable name fails", SchemaUtil.isTablePresent( "tbl_empl_sites", configuration() ) );
|
assertTrue( "Overridden @JoinTable name fails", SchemaUtil.isTablePresent( "tbl_empl_sites", metadata() ) );
|
||||||
assertTrue( "Overridden @JoinTable with default @JoinColumn fails",
|
assertTrue( "Overridden @JoinTable with default @JoinColumn fails",
|
||||||
SchemaUtil.isColumnPresent( "tbl_empl_sites", "employee_id", configuration() ) );
|
SchemaUtil.isColumnPresent( "tbl_empl_sites", "employee_id", metadata() ) );
|
||||||
assertTrue( "Overridden @JoinTable.inverseJoinColumn fails",
|
assertTrue( "Overridden @JoinTable.inverseJoinColumn fails",
|
||||||
SchemaUtil.isColumnPresent( "tbl_empl_sites", "to_website_fk", configuration() ) );
|
SchemaUtil.isColumnPresent( "tbl_empl_sites", "to_website_fk", metadata() ) );
|
||||||
|
|
||||||
Session s = openSession();
|
Session s = openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class AttributeOverrideTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isColumnPresent(String tableName, String columnName) {
|
public boolean isColumnPresent(String tableName, String columnName) {
|
||||||
return SchemaUtil.isColumnPresent( tableName, columnName, configuration() );
|
return SchemaUtil.isColumnPresent( tableName, columnName, metadata() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,15 +23,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.persister;
|
package org.hibernate.test.annotations.persister;
|
||||||
|
|
||||||
import org.junit.Test;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.SingleTableEntityPersister;
|
import org.hibernate.persister.entity.SingleTableEntityPersister;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shawn Clowater
|
* @author Shawn Clowater
|
||||||
|
@ -41,21 +40,22 @@ public class PersisterTest extends BaseCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testEntityEntityPersisterAndPersisterSpecified() throws Exception {
|
public void testEntityEntityPersisterAndPersisterSpecified() throws Exception {
|
||||||
//checks to see that the persister specified with the @Persister annotation takes precedence if a @Entity.persister() is also specified
|
//checks to see that the persister specified with the @Persister annotation takes precedence if a @Entity.persister() is also specified
|
||||||
PersistentClass persistentClass = configuration().getClassMapping( Deck.class.getName() );
|
Class<? extends EntityPersister> clazz = getEntityBinding( Deck.class ).getCustomEntityPersisterClass();
|
||||||
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(), EntityPersister.class,
|
assertEquals( "Incorrect Persister class for " + Deck.class.getName(),
|
||||||
persistentClass.getEntityPersisterClass() );
|
EntityPersister.class, clazz );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityEntityPersisterSpecified() throws Exception {
|
public void testEntityEntityPersisterSpecified() throws Exception {
|
||||||
//tests the persister specified with an @Entity.persister()
|
//tests the persister specified with an @Entity.persister()
|
||||||
PersistentClass persistentClass = configuration().getClassMapping( Card.class.getName() );
|
Class<? extends EntityPersister> clazz = getEntityBinding( Card.class ).getCustomEntityPersisterClass();
|
||||||
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(),
|
assertEquals( "Incorrect Persister class for " + Card.class.getName(),
|
||||||
SingleTableEntityPersister.class, persistentClass.getEntityPersisterClass() );
|
SingleTableEntityPersister.class, clazz );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCollectionPersisterSpecified() throws Exception {
|
public void testCollectionPersisterSpecified() throws Exception {
|
||||||
|
// TODO: use getCollectionBindings()
|
||||||
//tests the persister specified by the @Persister annotation on a collection
|
//tests the persister specified by the @Persister annotation on a collection
|
||||||
Collection collection = configuration().getCollectionMapping( Deck.class.getName() + ".cards" );
|
Collection collection = configuration().getCollectionMapping( Deck.class.getName() + ".cards" );
|
||||||
assertEquals( "Incorrect Persister class for collection " + collection.getRole(), CollectionPersister.class,
|
assertEquals( "Incorrect Persister class for collection " + collection.getRole(), CollectionPersister.class,
|
||||||
|
|
|
@ -23,49 +23,48 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.various;
|
package org.hibernate.test.annotations.various;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.mapping.PersistentClass;
|
|
||||||
import org.hibernate.mapping.Property;
|
|
||||||
import org.hibernate.metadata.ClassMetadata;
|
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|
||||||
import org.hibernate.type.DbTimestampType;
|
|
||||||
import org.hibernate.type.TimestampType;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.hibernate.metadata.ClassMetadata;
|
||||||
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.hibernate.type.DbTimestampType;
|
||||||
|
import org.hibernate.type.TimestampType;
|
||||||
|
import org.hibernate.type.Type;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for the @Timestamp annotation.
|
* Test for the @Timestamp annotation.
|
||||||
*
|
*
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public class TimestampTest extends BaseCoreFunctionalTestCase {
|
public class TimestampTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testTimestampSourceIsVM() throws Exception {
|
public void testTimestampSourceIsVM() throws Exception {
|
||||||
assertTimestampSource( VMTimestamped.class, TimestampType.class );
|
assertTimestampSource( VMTimestamped.class, TimestampType.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@FailureExpectedWithNewMetamodel
|
|
||||||
public void testTimestampSourceIsDB() throws Exception {
|
public void testTimestampSourceIsDB() throws Exception {
|
||||||
assertTimestampSource( DBTimestamped.class, DbTimestampType.class );
|
assertTimestampSource( DBTimestamped.class, DbTimestampType.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertTimestampSource(Class<?> clazz, Class<?> expectedTypeClass) throws Exception {
|
private void assertTimestampSource(Class<?> clazz, Class<?> expectedTypeClass) throws Exception {
|
||||||
buildConfiguration();
|
|
||||||
ClassMetadata meta = sessionFactory().getClassMetadata( clazz );
|
ClassMetadata meta = sessionFactory().getClassMetadata( clazz );
|
||||||
assertTrue( "Entity is annotated with @Timestamp and should hence be versioned", meta.isVersioned() );
|
assertTrue( "Entity is annotated with @Timestamp and should hence be versioned", meta.isVersioned() );
|
||||||
|
|
||||||
PersistentClass persistentClass = configuration().getClassMapping( clazz.getName() );
|
EntityBinding binding = getEntityBinding( clazz );
|
||||||
assertNotNull( persistentClass );
|
assertNotNull( binding );
|
||||||
Property versionProperty = persistentClass.getVersion();
|
Type type = binding.getHierarchyDetails().getEntityVersion()
|
||||||
assertNotNull( versionProperty );
|
.getVersioningAttributeBinding().getHibernateTypeDescriptor()
|
||||||
assertEquals( "Wrong timestamp type", expectedTypeClass, versionProperty.getType().getClass() );
|
.getResolvedTypeMapping();
|
||||||
|
assertNotNull( type );
|
||||||
|
assertEquals( "Wrong timestamp type", expectedTypeClass,
|
||||||
|
type.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,23 +23,23 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.xml.ejb3;
|
package org.hibernate.test.annotations.xml.ejb3;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
@TestForIssue(jiraKey = "HHH-6271")
|
@TestForIssue(jiraKey = "HHH-6271")
|
||||||
public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase {
|
public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNonExistentOrmVersion() {
|
public void testNonExistentOrmVersion() {
|
||||||
try {
|
try {
|
||||||
Configuration config = buildConfiguration();
|
Configuration config = configuration();
|
||||||
String xmlFileName = "org/hibernate/test/annotations/xml/ejb3/orm5.xml";
|
String xmlFileName = "org/hibernate/test/annotations/xml/ejb3/orm5.xml";
|
||||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFileName );
|
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFileName );
|
||||||
config.addInputStream( is );
|
config.addInputStream( is );
|
||||||
|
|
|
@ -23,6 +23,10 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.legacy;
|
package org.hibernate.test.legacy;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -32,8 +36,6 @@ import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.ObjectNotFoundException;
|
import org.hibernate.ObjectNotFoundException;
|
||||||
|
@ -47,14 +49,11 @@ import org.hibernate.dialect.MckoiDialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.SAPDBDialect;
|
import org.hibernate.dialect.SAPDBDialect;
|
||||||
import org.hibernate.jdbc.AbstractWork;
|
import org.hibernate.jdbc.AbstractWork;
|
||||||
import org.hibernate.mapping.MetaAttribute;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.metamodel.spi.binding.MetaAttribute;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.SkipLog;
|
import org.hibernate.testing.SkipLog;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
|
|
||||||
@FailureExpectedWithNewMetamodel
|
@FailureExpectedWithNewMetamodel
|
||||||
|
@ -104,10 +103,10 @@ public class MasterDetailTest extends LegacyTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMeta() throws Exception {
|
public void testMeta() throws Exception {
|
||||||
PersistentClass clazz = configuration().getClassMapping( Master.class.getName() );
|
EntityBinding binding = getEntityBinding( Master.class );
|
||||||
MetaAttribute meta = clazz.getMetaAttribute("foo");
|
MetaAttribute meta = binding.getMetaAttributeContext().getMetaAttribute("foo");
|
||||||
assertTrue( "foo".equals( meta.getValue() ) );
|
assertTrue( "foo".equals( meta.getValue() ) );
|
||||||
meta = clazz.getProperty("name").getMetaAttribute("bar");
|
meta = binding.getMetaAttributeContext().getMetaAttribute("bar");
|
||||||
assertTrue( meta.isMultiValued() );
|
assertTrue( meta.isMultiValued() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,16 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.propertyref.basic;
|
package org.hibernate.test.propertyref.basic;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import org.hibernate.FetchMode;
|
import org.hibernate.FetchMode;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
@ -36,16 +41,11 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.ForeignKey;
|
import org.hibernate.mapping.ForeignKey;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||||
|
import org.hibernate.test.util.SchemaUtil;
|
||||||
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
|
||||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
import org.junit.Test;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
@ -273,9 +273,9 @@ public class PropertyRefTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testForeignKeyCreation() {
|
public void testForeignKeyCreation() {
|
||||||
PersistentClass classMapping = configuration().getClassMapping("org.hibernate.test.propertyref.basic.Account");
|
TableSpecification table = SchemaUtil.getTable( Account.class, metadata() );
|
||||||
|
|
||||||
Iterator foreignKeyIterator = classMapping.getTable().getForeignKeyIterator();
|
Iterator foreignKeyIterator = table.getForeignKeys().iterator();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
while ( foreignKeyIterator.hasNext() ) {
|
while ( foreignKeyIterator.hasNext() ) {
|
||||||
ForeignKey element = (ForeignKey) foreignKeyIterator.next();
|
ForeignKey element = (ForeignKey) foreignKeyIterator.next();
|
||||||
|
|
|
@ -22,43 +22,67 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.util;
|
package org.hibernate.test.util;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.metamodel.Metadata;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
|
import org.hibernate.metamodel.spi.relational.Column;
|
||||||
|
import org.hibernate.metamodel.spi.relational.Index;
|
||||||
|
import org.hibernate.metamodel.spi.relational.TableSpecification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the Hibernate metamodel contains some database objects
|
* Check that the Hibernate metamodel contains some database objects
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bernard
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public abstract class SchemaUtil {
|
public abstract class SchemaUtil {
|
||||||
public static boolean isColumnPresent(String tableName, String columnName, Configuration cfg) {
|
|
||||||
final Iterator<Table> tables = ( Iterator<Table> ) cfg.getTableMappings();
|
public static boolean isColumnPresent(
|
||||||
while (tables.hasNext()) {
|
String tableName, String columnName, Metadata metadata ) {
|
||||||
Table table = tables.next();
|
try {
|
||||||
if (tableName.equals( table.getName() ) ) {
|
TableSpecification table = getTable( tableName, metadata );
|
||||||
Iterator<Column> columns = (Iterator<Column>) table.getColumnIterator();
|
return ( table.locateColumn( columnName ) == null ) ? false : true;
|
||||||
while ( columns.hasNext() ) {
|
} catch ( AssertionFailure e ) {
|
||||||
Column column = columns.next();
|
return false;
|
||||||
if ( columnName.equals( column.getName() ) ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isTablePresent(String tableName, Configuration cfg) {
|
public static boolean isTablePresent( String tableName, Metadata metadata ) {
|
||||||
final Iterator<Table> tables = ( Iterator<Table> ) cfg.getTableMappings();
|
try {
|
||||||
while (tables.hasNext()) {
|
TableSpecification table = getTable( tableName, metadata );
|
||||||
Table table = tables.next();
|
return ( table == null ) ? false : true;
|
||||||
if (tableName.equals( table.getName() ) ) {
|
} catch ( AssertionFailure e ) {
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
public static TableSpecification getTable(
|
||||||
|
Class<?> entityClass, Metadata metadata ) throws AssertionFailure {
|
||||||
|
final EntityBinding binding = metadata.getEntityBinding(
|
||||||
|
entityClass.getName() );
|
||||||
|
return binding.getPrimaryTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TableSpecification getTable(
|
||||||
|
String tableName, Metadata metadata ) throws AssertionFailure {
|
||||||
|
final EntityBinding binding = metadata.getEntityBinding( tableName );
|
||||||
|
return binding.locateTable( tableName );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Column getColumn( Class<?> entityClass, String columnName,
|
||||||
|
Metadata metadata ) throws AssertionFailure {
|
||||||
|
return getTable( entityClass, metadata ).locateColumn( columnName );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Column getColumn( String tableName, String columnName,
|
||||||
|
Metadata metadata ) throws AssertionFailure {
|
||||||
|
return getTable( tableName, metadata ).locateColumn( columnName );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Iterator<Index> getIndexes( Class<?> entityClass,
|
||||||
|
Metadata metadata ) throws AssertionFailure {
|
||||||
|
return getTable( entityClass, metadata ).getIndexes().iterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.testing.junit4;
|
package org.hibernate.testing.junit4;
|
||||||
|
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.sql.Blob;
|
import java.sql.Blob;
|
||||||
import java.sql.Clob;
|
import java.sql.Clob;
|
||||||
|
@ -65,26 +67,22 @@ import org.hibernate.metamodel.spi.binding.AbstractPluralAttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
import org.hibernate.metamodel.spi.binding.AttributeBinding;
|
||||||
import org.hibernate.metamodel.spi.binding.Caching;
|
import org.hibernate.metamodel.spi.binding.Caching;
|
||||||
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
import org.hibernate.metamodel.spi.binding.EntityBinding;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
|
||||||
|
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
import org.hibernate.testing.AfterClassOnce;
|
import org.hibernate.testing.AfterClassOnce;
|
||||||
import org.hibernate.testing.BeforeClassOnce;
|
import org.hibernate.testing.BeforeClassOnce;
|
||||||
import org.hibernate.testing.OnExpectedFailure;
|
import org.hibernate.testing.OnExpectedFailure;
|
||||||
import org.hibernate.testing.OnFailure;
|
import org.hibernate.testing.OnFailure;
|
||||||
import org.hibernate.testing.SkipLog;
|
import org.hibernate.testing.SkipLog;
|
||||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
import org.hibernate.testing.cache.CachingRegionFactory;
|
||||||
|
import org.hibernate.type.Type;
|
||||||
import static org.junit.Assert.fail;
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies functional testing logic for core Hibernate testing on top of {@link BaseUnitTestCase}
|
* Applies functional testing logic for core Hibernate testing on top of {@link BaseUnitTestCase}
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings( {"deprecation"} )
|
|
||||||
public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
public static final String VALIDATE_DATA_CLEANUP = "hibernate.test.validateDataCleanup";
|
public static final String VALIDATE_DATA_CLEANUP = "hibernate.test.validateDataCleanup";
|
||||||
public static final String USE_NEW_METADATA_MAPPINGS = "hibernate.test.new_metadata_mappings";
|
public static final String USE_NEW_METADATA_MAPPINGS = "hibernate.test.new_metadata_mappings";
|
||||||
|
@ -93,6 +91,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
|
|
||||||
private boolean isMetadataUsed;
|
private boolean isMetadataUsed;
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
private MetadataImplementor metadataImplementor;
|
||||||
private StandardServiceRegistryImpl serviceRegistry;
|
private StandardServiceRegistryImpl serviceRegistry;
|
||||||
private SessionFactoryImplementor sessionFactory;
|
private SessionFactoryImplementor sessionFactory;
|
||||||
|
|
||||||
|
@ -106,6 +105,22 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected MetadataImplementor metadata() {
|
||||||
|
return metadataImplementor;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EntityBinding getEntityBinding(Class<?> clazz) {
|
||||||
|
return metadataImplementor.getEntityBinding( clazz.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected EntityBinding getRootEntityBinding(Class<?> clazz) {
|
||||||
|
return metadataImplementor.getRootEntityBinding( clazz.getName() );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Iterator<PluralAttributeBinding> getCollectionBindings() {
|
||||||
|
return metadataImplementor.getCollectionBindings().iterator();
|
||||||
|
}
|
||||||
|
|
||||||
protected StandardServiceRegistryImpl serviceRegistry() {
|
protected StandardServiceRegistryImpl serviceRegistry() {
|
||||||
return serviceRegistry;
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +160,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
if ( isMetadataUsed ) {
|
if ( isMetadataUsed ) {
|
||||||
MetadataImplementor metadataImplementor = buildMetadata( bootRegistry, serviceRegistry );
|
metadataImplementor = buildMetadata( bootRegistry, serviceRegistry );
|
||||||
afterConstructAndConfigureMetadata( metadataImplementor );
|
afterConstructAndConfigureMetadata( metadataImplementor );
|
||||||
applyCacheSettings(metadataImplementor);
|
applyCacheSettings(metadataImplementor);
|
||||||
sessionFactory = ( SessionFactoryImplementor ) metadataImplementor.buildSessionFactory();
|
sessionFactory = ( SessionFactoryImplementor ) metadataImplementor.buildSessionFactory();
|
||||||
|
@ -178,13 +193,6 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
|
||||||
return (MetadataImplementor) sources.getMetadataBuilder( serviceRegistry ).build();
|
return (MetadataImplementor) sources.getMetadataBuilder( serviceRegistry ).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: is this still needed?
|
|
||||||
protected Configuration buildConfiguration() {
|
|
||||||
Configuration cfg = constructAndConfigureConfiguration();
|
|
||||||
afterConstructAndConfigureConfiguration( cfg );
|
|
||||||
return cfg;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Configuration constructAndConfigureConfiguration() {
|
private Configuration constructAndConfigureConfiguration() {
|
||||||
Configuration cfg = constructConfiguration();
|
Configuration cfg = constructConfiguration();
|
||||||
configure( cfg );
|
configure( cfg );
|
||||||
|
|
Loading…
Reference in New Issue