HHH-7569 Merging test changes to master that were made only in 4.1
branch
This commit is contained in:
parent
6a48cccd5d
commit
7b04acd4f4
|
@ -34,7 +34,6 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
|
||||
import org.dom4j.Node;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -43,14 +42,14 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.SerializationHelper;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
import org.hibernate.usertype.DynamicParameterizedType;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class SerializableToBlobType extends AbstractLobType implements ParameterizedType {
|
||||
public class SerializableToBlobType extends AbstractLobType implements DynamicParameterizedType {
|
||||
/**
|
||||
* class name of the serialisable class
|
||||
* class name of the serialisable class
|
||||
*/
|
||||
public static final String CLASS_NAME = "classname";
|
||||
private Class serializableClass;
|
||||
|
@ -138,17 +137,19 @@ public class SerializableToBlobType extends AbstractLobType implements Parameter
|
|||
}
|
||||
|
||||
public void setParameterValues(Properties parameters) {
|
||||
if ( parameters != null ) {
|
||||
ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE );
|
||||
if ( reader != null ) {
|
||||
serializableClass = reader.getReturnedClass();
|
||||
}
|
||||
else {
|
||||
String className = parameters.getProperty( CLASS_NAME );
|
||||
if ( className == null ) {
|
||||
throw new MappingException(
|
||||
"No class name defined for type: " + SerializableToBlobType.class.getName()
|
||||
);
|
||||
throw new MappingException( "No class name defined for type: " + SerializableToBlobType.class.getName() );
|
||||
}
|
||||
try {
|
||||
serializableClass = ReflectHelper.classForName( className );
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
catch ( ClassNotFoundException e ) {
|
||||
throw new MappingException( "Unable to load class from " + CLASS_NAME + " parameter", e );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,14 +24,20 @@
|
|||
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.id.Assigned;
|
||||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.id.IdentityGenerator;
|
||||
|
@ -42,17 +48,13 @@ import org.hibernate.metamodel.MetadataSources;
|
|||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.EntityIdentifier;
|
||||
import org.hibernate.metamodel.source.MappingException;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertNotNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static junit.framework.Assert.fail;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class IdentifierGeneratorTest extends BaseAnnotationBindingTestCase {
|
||||
@Entity
|
||||
class NoGenerationEntity {
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.OrderBy;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -74,6 +75,7 @@ public class Person {
|
|||
|
||||
@ElementCollection
|
||||
@JoinColumn
|
||||
@JoinTable(name = "T_NICKNAMES_A")
|
||||
@OrderBy
|
||||
public Set<String> getNickNamesAscendingNaturalSort() {
|
||||
return nickNamesAscendingNaturalSort;
|
||||
|
@ -85,6 +87,7 @@ public class Person {
|
|||
|
||||
@ElementCollection
|
||||
@JoinColumn
|
||||
@JoinTable(name = "T_NICKNAMES_D")
|
||||
@OrderBy( "desc" )
|
||||
public Set<String> getNickNamesDescendingNaturalSort() {
|
||||
return nickNamesDescendingNaturalSort;
|
||||
|
@ -98,6 +101,7 @@ public class Person {
|
|||
@ElementCollection
|
||||
@JoinColumn
|
||||
@OrderBy
|
||||
@JoinTable(name = "T_ADDRESS_A")
|
||||
public Set<Address> getAddressesAscendingNaturalSort() {
|
||||
return addressesAscendingNaturalSort;
|
||||
}
|
||||
|
@ -109,6 +113,7 @@ public class Person {
|
|||
@ElementCollection
|
||||
@JoinColumn
|
||||
@OrderBy( "desc" )
|
||||
@JoinTable(name = "T_ADDRESS_D")
|
||||
public Set<Address> getAddressesDescendingNaturalSort() {
|
||||
return addressesDescendingNaturalSort;
|
||||
}
|
||||
|
@ -120,6 +125,7 @@ public class Person {
|
|||
@ElementCollection
|
||||
@JoinColumn
|
||||
@OrderBy( "city" )
|
||||
@JoinTable(name = "T_ADD_CITY_A")
|
||||
public Set<Address> getAddressesCityAscendingSort() {
|
||||
return addressesCityAscendingSort;
|
||||
}
|
||||
|
@ -131,6 +137,7 @@ public class Person {
|
|||
@ElementCollection
|
||||
@JoinColumn
|
||||
@OrderBy( "city desc" )
|
||||
@JoinTable(name = "T_ADD_CITY_D")
|
||||
public Set<Address> getAddressesCityDescendingSort() {
|
||||
return addressesCityDescendingSort;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
package org.hibernate.test.annotations.embeddables;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -32,20 +34,19 @@ import org.hibernate.Session;
|
|||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.exception.GenericJDBCException;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Chris Pheby
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class EmbeddableIntegratorTest extends BaseUnitTestCase {
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,13 +11,14 @@ import org.hibernate.annotations.Filter;
|
|||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
import org.hibernate.annotations.SqlFragmentAlias;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="USER")
|
||||
@Table(name="T_USER")
|
||||
@SecondaryTable(name="SECURITY_USER")
|
||||
@FilterDef(name="ageFilter", parameters=@ParamDef(name="age", type="integer"))
|
||||
@Filter(name="ageFilter", condition="{u}.AGE < :age AND {s}.LOCKED_OUT <> 1",
|
||||
aliases={@SqlFragmentAlias(alias="u", table="USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")})
|
||||
aliases={@SqlFragmentAlias(alias="u", table="T_USER"), @SqlFragmentAlias(alias="s", table="SECURITY_USER")})
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
|
@ -31,13 +32,14 @@ public class User {
|
|||
@Column(name="AGE")
|
||||
private int age;
|
||||
|
||||
@Column(name="USERNAME", table="SECURITY_USER")
|
||||
@Column(name="SECURITY_USERNAME", table="SECURITY_USER")
|
||||
private String username;
|
||||
|
||||
@Column(name="PASSWORD", table="SECURITY_USER")
|
||||
@Column(name="SECURITY_PASSWORD", table="SECURITY_USER")
|
||||
private String password;
|
||||
|
||||
@Column(name="LOCKED_OUT", table="SECURITY_USER")
|
||||
@Type( type = "numeric_boolean")
|
||||
private boolean lockedOut;
|
||||
|
||||
public int getId() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -6,6 +6,7 @@ import javax.persistence.Table;
|
|||
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
@Entity
|
||||
@Table(name="ZOOLOGY_MAMMAL")
|
||||
|
@ -14,6 +15,7 @@ import org.hibernate.annotations.FilterDef;
|
|||
public class Mammal extends Animal{
|
||||
|
||||
@Column(name="IS_PREGNANT")
|
||||
@Type( type="numeric_boolean" )
|
||||
private boolean isPregnant;
|
||||
|
||||
public boolean isPregnant() {
|
||||
|
|
|
@ -7,11 +7,13 @@ import org.hibernate.Session;
|
|||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.test.annotations.id.sequences.entities.HibernateSequenceEntity;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
|
@ -19,6 +21,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
|||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-6068")
|
||||
@RequiresDialect( value = H2Dialect.class)
|
||||
public class HibernateSequenceTest extends BaseCoreFunctionalTestCase {
|
||||
private static final String SCHEMA_NAME = "OTHER_SCHEMA";
|
||||
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Lob;
|
||||
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.annotations.TypeDef;
|
||||
import org.hibernate.annotations.TypeDefs;
|
||||
|
||||
/**
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
@Entity
|
||||
@TypeDefs({ @TypeDef(typeClass = ImplicitSerializableType.class, defaultForType = ImplicitSerializable.class) })
|
||||
public class EntitySerialize {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
long id;
|
||||
|
||||
@Lob
|
||||
ExplicitSerializable explicitLob;
|
||||
|
||||
@Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
|
||||
ExplicitSerializable explicit;
|
||||
|
||||
ImplicitSerializable implicit;
|
||||
|
||||
@Type(type = "org.hibernate.test.annotations.lob.ExplicitSerializableType")
|
||||
ImplicitSerializable explicitOverridingImplicit;
|
||||
|
||||
/**
|
||||
* common in ExplicitSerializable and ImplicitSerializable to create same property in both
|
||||
* This property will not persist it have a default value per type
|
||||
*
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public interface CommonSerializable {
|
||||
String getDefaultValue();
|
||||
|
||||
void setDefaultValue(String defaultValue);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
|
||||
|
||||
/**
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public class ExplicitSerializable implements Serializable, CommonSerializable {
|
||||
String defaultValue;
|
||||
String value;
|
||||
|
||||
@Override
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
|
||||
import org.hibernate.type.SerializableToBlobType;
|
||||
|
||||
/**
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public class ExplicitSerializableType extends SerializableToBlobType {
|
||||
@Override
|
||||
public Object get(ResultSet rs, String name) throws SQLException {
|
||||
CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
|
||||
deserialize.setDefaultValue( "EXPLICIT" );
|
||||
return deserialize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
|
||||
if ( value != null ) {
|
||||
( (CommonSerializable) value ).setDefaultValue( null );
|
||||
}
|
||||
super.set( st, value, index, session );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
|
||||
|
||||
/**
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public class ImplicitSerializable implements Serializable, CommonSerializable {
|
||||
String defaultValue;
|
||||
String value;
|
||||
|
||||
@Override
|
||||
public String getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultValue(String defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.test.annotations.lob.EntitySerialize.CommonSerializable;
|
||||
import org.hibernate.type.SerializableToBlobType;
|
||||
|
||||
/**
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public class ImplicitSerializableType extends SerializableToBlobType {
|
||||
|
||||
@Override
|
||||
public Object get(ResultSet rs, String name) throws SQLException {
|
||||
CommonSerializable deserialize = (CommonSerializable) super.get( rs, name );
|
||||
deserialize.setDefaultValue( "IMPLICIT" );
|
||||
return deserialize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
|
||||
if ( value != null ) {
|
||||
( (CommonSerializable) value ).setDefaultValue( null );
|
||||
}
|
||||
super.set( st, value, index, session );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package org.hibernate.test.annotations.lob;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.type.SerializableToBlobType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Test type definition for SerializableToBlobType
|
||||
*
|
||||
* @author Janario Oliveira
|
||||
*/
|
||||
public class SerializableToBlobTypeTest extends BaseCoreFunctionalTestCase {
|
||||
@Test
|
||||
public void testTypeDefinition() {
|
||||
Configuration cfg = configuration();
|
||||
PersistentClass pc = cfg.getClassMapping( EntitySerialize.class.getName() );
|
||||
|
||||
// explicitLob of SerializableToBlobType
|
||||
Type explicitLobType = pc.getProperty( "explicitLob" ).getType();
|
||||
assertEquals( ExplicitSerializable.class, explicitLobType.getReturnedClass() );
|
||||
assertEquals( SerializableToBlobType.class.getName(), explicitLobType.getName() );
|
||||
|
||||
// explicit of ExplicitSerializableType
|
||||
Type explicitType = pc.getProperty( "explicit" ).getType();
|
||||
assertEquals( ExplicitSerializable.class, explicitType.getReturnedClass() );
|
||||
assertEquals( ExplicitSerializableType.class.getName(), explicitType.getName() );
|
||||
|
||||
// implicit of ImplicitSerializableType
|
||||
Type implicitType = pc.getProperty( "implicit" ).getType();
|
||||
assertEquals( ImplicitSerializable.class, implicitType.getReturnedClass() );
|
||||
assertEquals( ImplicitSerializableType.class.getName(), implicitType.getName() );
|
||||
|
||||
// explicitOverridingImplicit ExplicitSerializableType overrides ImplicitSerializableType
|
||||
Type overrideType = pc.getProperty( "explicitOverridingImplicit" ).getType();
|
||||
assertEquals( ImplicitSerializable.class, overrideType.getReturnedClass() );
|
||||
assertEquals( ExplicitSerializableType.class.getName(), overrideType.getName() );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersist() {
|
||||
EntitySerialize entitySerialize = new EntitySerialize();
|
||||
|
||||
entitySerialize.explicitLob = new ExplicitSerializable();
|
||||
entitySerialize.explicitLob.value = "explicitLob";
|
||||
entitySerialize.explicitLob.defaultValue = "defaultExplicitLob";
|
||||
|
||||
entitySerialize.explicit = new ExplicitSerializable();
|
||||
entitySerialize.explicit.value = "explicit";
|
||||
|
||||
entitySerialize.implicit = new ImplicitSerializable();
|
||||
entitySerialize.implicit.value = "implicit";
|
||||
|
||||
entitySerialize.explicitOverridingImplicit = new ImplicitSerializable();
|
||||
entitySerialize.explicitOverridingImplicit.value = "explicitOverridingImplicit";
|
||||
|
||||
Session session = openSession();
|
||||
session.getTransaction().begin();
|
||||
session.persist( entitySerialize );
|
||||
|
||||
session.getTransaction().commit();
|
||||
session.close();
|
||||
|
||||
session = openSession();
|
||||
|
||||
EntitySerialize persistedSerialize = (EntitySerialize) session.get( EntitySerialize.class, entitySerialize.id );
|
||||
assertEquals( "explicitLob", persistedSerialize.explicitLob.value );
|
||||
assertEquals( "explicit", persistedSerialize.explicit.value );
|
||||
assertEquals( "implicit", persistedSerialize.implicit.value );
|
||||
assertEquals( "explicitOverridingImplicit", persistedSerialize.explicitOverridingImplicit.value );
|
||||
|
||||
assertEquals( "defaultExplicitLob", persistedSerialize.explicitLob.defaultValue );
|
||||
assertEquals( "EXPLICIT", persistedSerialize.explicit.defaultValue );
|
||||
assertEquals( "IMPLICIT", persistedSerialize.implicit.defaultValue );
|
||||
assertEquals( "EXPLICIT", persistedSerialize.explicitOverridingImplicit.defaultValue );
|
||||
|
||||
session.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class[] getAnnotatedClasses() {
|
||||
return new Class[] { EntitySerialize.class };
|
||||
}
|
||||
}
|
|
@ -1,34 +1,36 @@
|
|||
// $Id: AggressiveReleaseTest.java 10977 2006-12-12 23:28:04Z steve.ebersole@jboss.com $
|
||||
package org.hibernate.test.connections;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||
import org.hibernate.internal.util.SerializationHelper;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Implementation of AggressiveReleaseTest.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class AggressiveReleaseTest extends ConnectionManagementTestCase {
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
|
|
|
@ -27,12 +27,15 @@ import org.hibernate.ConnectionReleaseMode;
|
|||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
||||
/**
|
||||
* Implementation of BasicConnectionProviderTest.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class BasicConnectionProviderTest extends ConnectionManagementTestCase {
|
||||
@Override
|
||||
protected Session getSessionUnderTest() {
|
||||
|
|
|
@ -26,7 +26,9 @@ import org.junit.Test;
|
|||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.internal.util.SerializationHelper;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -45,6 +47,7 @@ import static org.junit.Assert.fail;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
||||
public abstract class ConnectionManagementTestCase extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
public final String[] getMappings() {
|
||||
|
|
|
@ -24,12 +24,15 @@
|
|||
package org.hibernate.test.connections;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
||||
/**
|
||||
* Implementation of CurrentSessionConnectionTest.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class CurrentSessionConnectionTest extends AggressiveReleaseTest {
|
||||
@Override
|
||||
protected Session getSessionUnderTest() throws Throwable {
|
||||
|
|
|
@ -31,11 +31,13 @@ import org.hibernate.ConnectionReleaseMode;
|
|||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.service.spi.Stoppable;
|
||||
import org.hibernate.testing.AfterClassOnce;
|
||||
import org.hibernate.testing.BeforeClassOnce;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.env.ConnectionProviderBuilder;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
|
@ -44,6 +46,7 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class SuppliedConnectionTest extends ConnectionManagementTestCase {
|
||||
private ConnectionProvider cp = ConnectionProviderBuilder.buildConnectionProvider();
|
||||
private Connection connectionUnderTest;
|
||||
|
|
|
@ -30,8 +30,10 @@ import org.hibernate.Session;
|
|||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.context.internal.ThreadLocalSessionContext;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.transaction.spi.LocalStatus;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -41,6 +43,7 @@ import static org.junit.Assert.fail;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class ThreadLocalCurrentSessionTest extends ConnectionManagementTestCase {
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
|
|
|
@ -26,7 +26,8 @@ package org.hibernate.test.fileimport;
|
|||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
|
||||
import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
||||
|
@ -35,6 +36,10 @@ import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
|
|||
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-2403" )
|
||||
@RequiresDialect(value = H2Dialect.class,
|
||||
jiraKey = "HHH-6286",
|
||||
comment = "Only running the tests against H2, because the sql statements in the import file are not generic. " +
|
||||
"This test should actually not test directly against the db")
|
||||
public class CommandExtractorServiceTest extends MultiLineImportFileTest {
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
*/
|
||||
package org.hibernate.test.propertyref;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class DoesNotWorkTest extends BaseCoreFunctionalTestCase {
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
|
|
|
@ -23,22 +23,23 @@
|
|||
*/
|
||||
package org.hibernate.test.propertyref;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class DoesNotWorkWithHbmTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -37,19 +37,6 @@ import org.hibernate.tool.hbm2ddl.SchemaExport;
|
|||
*/
|
||||
public class SchemaExportSuppliedConnectionTest extends SchemaExportTest {
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
serviceRegistry = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SchemaExport createSchemaExport(Configuration cfg) {
|
||||
return new SchemaExport( serviceRegistry, cfg );
|
||||
|
|
|
@ -23,10 +23,15 @@
|
|||
*/
|
||||
package org.hibernate.test.schemaupdate;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
|
||||
|
@ -44,6 +49,22 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
return Dialect.getDialect().supportsIfExistsAfterTableName() || Dialect.getDialect()
|
||||
.supportsIfExistsBeforeTableName();
|
||||
}
|
||||
protected ServiceRegistry serviceRegistry;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||
Configuration cfg = new Configuration();
|
||||
cfg.addResource( MAPPING );
|
||||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
schemaExport.drop( true, true );
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||
serviceRegistry = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndDropOnlyType() {
|
||||
|
@ -52,12 +73,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
// create w/o dropping first; (OK because tables don't exist yet
|
||||
schemaExport.execute( false, true, false, true );
|
||||
if ( doesDialectSupportDropTableIfExist() ) {
|
||||
// if ( doesDialectSupportDropTableIfExist() ) {
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
}
|
||||
else {
|
||||
assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
}
|
||||
// }
|
||||
// else {
|
||||
// assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
// }
|
||||
// create w/o dropping again; should be an exception for each table
|
||||
// (2 total) because the tables exist already
|
||||
// assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
|
@ -96,7 +117,12 @@ public abstract class SchemaExportTest extends BaseUnitTestCase {
|
|||
SchemaExport schemaExport = createSchemaExport( cfg );
|
||||
// should drop before creating, but tables don't exist yet
|
||||
schemaExport.create( true, true );
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
if ( doesDialectSupportDropTableIfExist() ) {
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
}
|
||||
else {
|
||||
assertEquals( 2, schemaExport.getExceptions().size() );
|
||||
}
|
||||
// call create again; it should drop tables before re-creating
|
||||
schemaExport.create( true, true );
|
||||
assertEquals( 0, schemaExport.getExceptions().size() );
|
||||
|
|
|
@ -23,27 +23,29 @@
|
|||
*/
|
||||
package org.hibernate.test.service;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
||||
import org.hibernate.engine.jdbc.connections.internal.UserSuppliedConnectionProviderImpl;
|
||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.env.ConnectionProviderBuilder;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect( H2Dialect.class )
|
||||
public class ServiceBootstrappingTest extends BaseUnitTestCase {
|
||||
@Test
|
||||
public void testBasicBuild() {
|
||||
|
|
|
@ -23,44 +23,47 @@
|
|||
*/
|
||||
package org.hibernate.test.transaction.jta;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import javax.transaction.TransactionManager;
|
||||
|
||||
import org.hibernate.ConnectionReleaseMode;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
|
||||
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
||||
import org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.engine.transaction.spi.TransactionContext;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
|
||||
import org.hibernate.test.common.JournalingTransactionObserver;
|
||||
import org.hibernate.test.common.TransactionContextImpl;
|
||||
import org.hibernate.test.common.TransactionEnvironmentImpl;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.jta.TestingJtaBootstrap;
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Testing transaction facade handling when the transaction is being driven by something other than the facade.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@RequiresDialect(H2Dialect.class)
|
||||
public class ManagedDrivingTest extends BaseUnitTestCase {
|
||||
private StandardServiceRegistryImpl serviceRegistry;
|
||||
|
||||
|
|
Loading…
Reference in New Issue