Merge branch '3.6' of github.com:hibernate/hibernate-core into 3.6
This commit is contained in:
commit
6b635a1472
|
@ -50,12 +50,12 @@ public class CacheHelper {
|
|||
|
||||
public static void initInternalEvict(CacheAdapter cacheAdapter, AddressAdapter member) {
|
||||
EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : member);
|
||||
cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL).put(eKey, Internal.INIT);
|
||||
cacheAdapter.withFlags(FlagAdapter.CACHE_MODE_LOCAL, FlagAdapter.SKIP_CACHE_LOAD).put(eKey, Internal.INIT);
|
||||
}
|
||||
|
||||
public static void sendEvictAllNotification(CacheAdapter cacheAdapter, AddressAdapter member) {
|
||||
EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : member);
|
||||
cacheAdapter.put(eKey, Internal.EVICT);
|
||||
cacheAdapter.withFlags(FlagAdapter.SKIP_CACHE_LOAD).put(eKey, Internal.EVICT);
|
||||
}
|
||||
|
||||
public static boolean isEvictAllNotification(Object key) {
|
||||
|
|
|
@ -36,7 +36,8 @@ public enum FlagAdapter {
|
|||
CACHE_MODE_LOCAL,
|
||||
FORCE_ASYNCHRONOUS,
|
||||
FORCE_SYNCHRONOUS,
|
||||
SKIP_CACHE_STORE;
|
||||
SKIP_CACHE_STORE,
|
||||
SKIP_CACHE_LOAD;
|
||||
|
||||
Flag toFlag() {
|
||||
switch(this) {
|
||||
|
@ -50,6 +51,8 @@ public enum FlagAdapter {
|
|||
return Flag.FORCE_SYNCHRONOUS;
|
||||
case SKIP_CACHE_STORE:
|
||||
return Flag.SKIP_CACHE_STORE;
|
||||
case SKIP_CACHE_LOAD:
|
||||
return Flag.SKIP_CACHE_LOAD;
|
||||
default:
|
||||
throw new CacheException("Unmatched Infinispan flag " + this);
|
||||
}
|
||||
|
|
|
@ -346,9 +346,19 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener
|
|||
Object propertyFromEntity = persister.getPropertyValue( entity, propertyName, source.getEntityMode() );
|
||||
Type propertyType = persister.getPropertyType( propertyName );
|
||||
EntityEntry copyEntry = source.getPersistenceContext().getEntry( copy );
|
||||
if ( propertyFromCopy == null || ! propertyType.isEntityType() ) {
|
||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
||||
"' is null or not an entity; " + propertyName + " =["+propertyFromCopy+"]");
|
||||
if ( propertyFromCopy == null ||
|
||||
propertyFromEntity == null ||
|
||||
! propertyType.isEntityType() ||
|
||||
! copyCache.containsKey( propertyFromEntity ) ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
String fullPropertyName = "property '" + copyEntry.getEntityName() + "." + propertyName;
|
||||
log.trace( fullPropertyName + " in copy is " + ( propertyFromCopy == null ? "null" : propertyFromCopy ) );
|
||||
log.trace( fullPropertyName + " in original is " + ( propertyFromCopy == null ? "null" : propertyFromCopy ) );
|
||||
log.trace( fullPropertyName + ( propertyType.isEntityType() ? " is" : " is not" ) + " an entity type" );
|
||||
if ( propertyFromEntity != null && ! copyCache.containsKey( propertyFromEntity ) ) {
|
||||
log.trace( fullPropertyName + " is not in copy cache" );
|
||||
}
|
||||
}
|
||||
if ( isNullabilityCheckedGlobal( source ) ) {
|
||||
throw ex;
|
||||
}
|
||||
|
@ -358,18 +368,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener
|
|||
saveTransientEntity( copy, entityName, requestedId, source, copyCache, false );
|
||||
}
|
||||
}
|
||||
if ( ! copyCache.containsKey( propertyFromEntity ) ) {
|
||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
||||
"' from original entity is not in copyCache; " + propertyName + " =["+propertyFromEntity+"]");
|
||||
if ( isNullabilityCheckedGlobal( source ) ) {
|
||||
throw ex;
|
||||
}
|
||||
else {
|
||||
// retry save w/o checking non-nullable properties
|
||||
// (the failure will be detected later)
|
||||
saveTransientEntity( copy, entityName, requestedId, source, copyCache, false );
|
||||
}
|
||||
}
|
||||
if ( log.isTraceEnabled() && propertyFromEntity != null ) {
|
||||
if ( ( ( EventCache ) copyCache ).isOperatedOn( propertyFromEntity ) ) {
|
||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
||||
"' from original entity is in copyCache and is in the process of being merged; " +
|
||||
|
@ -380,6 +379,7 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener
|
|||
"' from original entity is in copyCache and is not in the process of being merged; " +
|
||||
propertyName + " =["+propertyFromEntity+"]");
|
||||
}
|
||||
}
|
||||
// continue...; we'll find out if it ends up not getting saved later
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,6 @@ public class Tools {
|
|||
proxy.getHibernateLazyInitializer().getEntityName(),
|
||||
proxy.getHibernateLazyInitializer().getIdentifier()
|
||||
);
|
||||
proxy.getHibernateLazyInitializer().setImplementation( target );
|
||||
return target;
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.envers.test.integration.proxy;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.envers.test.AbstractEntityTest;
|
||||
import org.hibernate.envers.test.entities.onetomany.ListRefEdEntity;
|
||||
import org.hibernate.envers.test.entities.onetomany.ListRefIngEntity;
|
||||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Test case for HHH-5750: Proxied objects lose the temporary session used to
|
||||
* initialize them.
|
||||
*
|
||||
* @author Erik-Berndt Scheper
|
||||
*
|
||||
*/
|
||||
public class AuditedCollectionProxyTest extends AbstractEntityTest {
|
||||
|
||||
Integer id_ListRefEdEntity1;
|
||||
|
||||
public void configure(Ejb3Configuration cfg) {
|
||||
cfg.addAnnotatedClass(ListRefEdEntity.class);
|
||||
cfg.addAnnotatedClass(ListRefIngEntity.class);
|
||||
}
|
||||
|
||||
@BeforeClass(dependsOnMethods = "init")
|
||||
public void initData() {
|
||||
EntityManager em = getEntityManager();
|
||||
|
||||
ListRefEdEntity listReferencedEntity1 = new ListRefEdEntity(
|
||||
Integer.valueOf(1), "str1");
|
||||
ListRefIngEntity refingEntity1 = new ListRefIngEntity(
|
||||
Integer.valueOf(1), "refing1", listReferencedEntity1);
|
||||
|
||||
// Revision 1
|
||||
em.getTransaction().begin();
|
||||
em.persist(listReferencedEntity1);
|
||||
em.persist(refingEntity1);
|
||||
em.getTransaction().commit();
|
||||
|
||||
id_ListRefEdEntity1 = listReferencedEntity1.getId();
|
||||
|
||||
// Revision 2
|
||||
ListRefIngEntity refingEntity2 = new ListRefIngEntity(
|
||||
Integer.valueOf(2), "refing2", listReferencedEntity1);
|
||||
|
||||
em.getTransaction().begin();
|
||||
em.persist(refingEntity2);
|
||||
em.getTransaction().commit();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProxyIdentifier() {
|
||||
EntityManager em = getEntityManager();
|
||||
|
||||
ListRefEdEntity listReferencedEntity1 = em.getReference(
|
||||
ListRefEdEntity.class, id_ListRefEdEntity1);
|
||||
|
||||
assert listReferencedEntity1 instanceof HibernateProxy;
|
||||
|
||||
// Revision 3
|
||||
ListRefIngEntity refingEntity3 = new ListRefIngEntity(
|
||||
Integer.valueOf(3), "refing3", listReferencedEntity1);
|
||||
|
||||
em.getTransaction().begin();
|
||||
em.persist(refingEntity3);
|
||||
em.getTransaction().commit();
|
||||
|
||||
listReferencedEntity1.getReffering().size();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -16,15 +16,21 @@ import javax.persistence.Entity;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.Table;
|
||||
|
||||
public class Classes {
|
||||
|
||||
@Embeddable
|
||||
@Table(name="Edition")
|
||||
public static class Edition<T> {
|
||||
T name;
|
||||
}
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name="Book")
|
||||
public static class Book {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
|
@ -35,12 +41,15 @@ public class Classes {
|
|||
}
|
||||
|
||||
@Entity
|
||||
@Table(name="PopularBook")
|
||||
public static class PopularBook {
|
||||
@Id
|
||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||
Long id;
|
||||
|
||||
@ElementCollection
|
||||
@JoinTable(name="PopularBook_Editions",joinColumns={@JoinColumn(name="PopularBook_id")})
|
||||
|
||||
Set<Edition<String>> editions = new HashSet<Edition<String>>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,24 +52,24 @@ public class Staff {
|
|||
@Column(name="size_in_cm")
|
||||
@ColumnTransformer(
|
||||
forColumn = "size_in_cm",
|
||||
read = "size_in_cm / 2.54",
|
||||
write = "? * 2.54" )
|
||||
read = "size_in_cm / 2.54E0",
|
||||
write = "? * 2.54E0" )
|
||||
public double getSizeInInches() { return sizeInInches; }
|
||||
public void setSizeInInches(double sizeInInches) { this.sizeInInches = sizeInInches; }
|
||||
private double sizeInInches;
|
||||
|
||||
//Weird extra S to avoid potential SQL keywords
|
||||
@ColumnTransformer(
|
||||
read = "radiusS / 2.54",
|
||||
write = "? * 2.54" )
|
||||
read = "radiusS / 2.54E0",
|
||||
write = "? * 2.54E0" )
|
||||
public double getRadiusS() { return radiusS; }
|
||||
public void setRadiusS(double radiusS) { this.radiusS = radiusS; }
|
||||
private double radiusS;
|
||||
|
||||
@Column(name="diamet")
|
||||
@ColumnTransformer(
|
||||
read = "diamet / 2.54",
|
||||
write = "? * 2.54" )
|
||||
read = "diamet / 2.54E0",
|
||||
write = "? * 2.54E0" )
|
||||
public double getDiameter() { return diameter; }
|
||||
public void setDiameter(double diameter) { this.diameter = diameter; }
|
||||
private double diameter;
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.test.cascade.circle;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class MultiPathCircleCascadeCheckNullFalseDelayedInsertTest extends MultiPathCircleCascadeDelayedInsertTest {
|
||||
|
||||
public MultiPathCircleCascadeCheckNullFalseDelayedInsertTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( Environment.CHECK_NULLABILITY, "false" );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( MultiPathCircleCascadeCheckNullFalseDelayedInsertTest.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.test.cascade.circle;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class MultiPathCircleCascadeCheckNullTrueDelayedInsertTest extends MultiPathCircleCascadeDelayedInsertTest {
|
||||
|
||||
public MultiPathCircleCascadeCheckNullTrueDelayedInsertTest(String str) {
|
||||
super( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( Environment.CHECK_NULLABILITY, "true" );
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( MultiPathCircleCascadeCheckNullTrueDelayedInsertTest.class );
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE hibernate-mapping SYSTEM "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd" >
|
||||
|
||||
<hibernate-mapping package="org.hibernate.test.cascade.circle">
|
||||
|
||||
<class name="Route" table="HB_Route">
|
||||
|
||||
<id name="routeID" type="long"><generator class="increment"/></id>
|
||||
|
||||
<property name="name" type="string" not-null="true"/>
|
||||
|
||||
<set name="nodes" inverse="true" cascade="persist,merge,refresh">
|
||||
<key column="routeID"/>
|
||||
<one-to-many class="Node"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Tour" table="HB_Tour">
|
||||
|
||||
<id name="tourID" type="long"><generator class="increment"/></id>
|
||||
|
||||
<property name="name" type="string" not-null="true"/>
|
||||
|
||||
<set name="nodes" inverse="true" lazy="true" cascade="merge,refresh">
|
||||
<key column="tourID"/>
|
||||
<one-to-many class="Node"/>
|
||||
</set>
|
||||
</class>
|
||||
|
||||
<class name="Transport" table="HB_Transport">
|
||||
|
||||
<id name="transportID" type="long"><generator class="increment"/></id>
|
||||
|
||||
<property name="name" type="string" not-null="true"/>
|
||||
|
||||
<many-to-one name="pickupNode"
|
||||
column="pickupNodeID"
|
||||
unique="true"
|
||||
not-null="true"
|
||||
cascade="merge,refresh"
|
||||
lazy="false"/>
|
||||
|
||||
<many-to-one name="deliveryNode"
|
||||
column="deliveryNodeID"
|
||||
unique="true"
|
||||
not-null="true"
|
||||
cascade="merge,refresh"
|
||||
lazy="false"/>
|
||||
</class>
|
||||
|
||||
<class name="Node" table="HB_Node">
|
||||
|
||||
<id name="nodeID" type="long"><generator class="increment"/></id>
|
||||
|
||||
<property name="name" type="string" not-null="true"/>
|
||||
|
||||
<set name="deliveryTransports" inverse="true" lazy="true" cascade="merge,refresh">
|
||||
<key column="deliveryNodeID"/>
|
||||
<one-to-many class="Transport"/>
|
||||
</set>
|
||||
|
||||
<set name="pickupTransports" inverse="true" lazy="true" cascade="merge,refresh">
|
||||
<key column="pickupNodeID"/>
|
||||
<one-to-many class="Transport"/>
|
||||
</set>
|
||||
|
||||
<many-to-one name="route"
|
||||
column="routeID"
|
||||
unique="false"
|
||||
not-null="true"
|
||||
cascade="none"
|
||||
lazy="false"/>
|
||||
|
||||
<many-to-one name="tour"
|
||||
column="tourID"
|
||||
unique="false"
|
||||
not-null="false"
|
||||
cascade="merge,refresh"
|
||||
lazy="false"/>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
package org.hibernate.test.cascade.circle;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
||||
import org.hibernate.JDBCException;
|
||||
import org.hibernate.PropertyValueException;
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class MultiPathCircleCascadeDelayedInsertTest extends MultiPathCircleCascadeTest {
|
||||
public MultiPathCircleCascadeDelayedInsertTest(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public String[] getMappings() {
|
||||
return new String[] {
|
||||
"cascade/circle/MultiPathCircleCascadeDelayedInsert.hbm.xml"
|
||||
};
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return new FunctionalTestClassTestSuite( MultiPathCircleCascadeDelayedInsertTest.class );
|
||||
}
|
||||
|
||||
protected void checkExceptionFromNullValueForNonNullable(Exception ex, boolean checkNullability, boolean isNullValue ) {
|
||||
if ( checkNullability ) {
|
||||
if ( isNullValue ) {
|
||||
assertTrue( ex instanceof PropertyValueException );
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof TransientObjectException );
|
||||
}
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof JDBCException || ex instanceof TransientObjectException );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -109,15 +109,15 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
|||
|
||||
try {
|
||||
s.merge( node );
|
||||
s.getTransaction().commit();
|
||||
fail( "should have thrown an exception" );
|
||||
}
|
||||
catch ( Exception ex ) {
|
||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
||||
assertTrue( ex instanceof TransientObjectException );
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof JDBCException );
|
||||
}
|
||||
checkExceptionFromNullValueForNonNullable(
|
||||
ex,
|
||||
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||
false
|
||||
);
|
||||
}
|
||||
finally {
|
||||
s.getTransaction().rollback();
|
||||
|
@ -138,15 +138,15 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
|||
|
||||
try {
|
||||
s.merge( node );
|
||||
s.getTransaction().commit();
|
||||
fail( "should have thrown an exception" );
|
||||
}
|
||||
catch ( Exception ex ) {
|
||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
||||
assertTrue( ex instanceof PropertyValueException );
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof JDBCException );
|
||||
}
|
||||
checkExceptionFromNullValueForNonNullable(
|
||||
ex,
|
||||
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||
true
|
||||
);
|
||||
}
|
||||
finally {
|
||||
s.getTransaction().rollback();
|
||||
|
@ -165,15 +165,15 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
|||
|
||||
try {
|
||||
s.merge( route );
|
||||
s.getTransaction().commit();
|
||||
fail( "should have thrown an exception" );
|
||||
}
|
||||
catch ( Exception ex ) {
|
||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
||||
assertTrue( ex instanceof PropertyValueException );
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof JDBCException );
|
||||
}
|
||||
checkExceptionFromNullValueForNonNullable(
|
||||
ex,
|
||||
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||
true
|
||||
);
|
||||
}
|
||||
finally {
|
||||
s.getTransaction().rollback();
|
||||
|
@ -531,6 +531,20 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
|||
assertUpdateCount( 1 );
|
||||
}
|
||||
|
||||
protected void checkExceptionFromNullValueForNonNullable(Exception ex, boolean checkNullability, boolean isNullValue ) {
|
||||
if ( checkNullability ) {
|
||||
if ( isNullValue ) {
|
||||
assertTrue( ex instanceof PropertyValueException );
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof TransientObjectException );
|
||||
}
|
||||
}
|
||||
else {
|
||||
assertTrue( ex instanceof JDBCException );
|
||||
}
|
||||
}
|
||||
|
||||
protected void clearCounts() {
|
||||
getSessions().getStatistics().clear();
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
<property name="currentAddress"
|
||||
column="address"
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
<property name="weightPounds">
|
||||
<column name="weight_kg"
|
||||
not-null="true"
|
||||
write="0.453 * ?"
|
||||
read="weight_kg / 0.453"/>
|
||||
write="0.453E0 * ?"
|
||||
read="weight_kg / 0.453E0"/>
|
||||
</property>
|
||||
|
||||
<property name="effectiveStartDate" column="eff_start_dt" type="java.util.Date"/>
|
||||
|
|
|
@ -307,7 +307,7 @@ public class ASTParserLoadingTest extends FunctionalTestCase {
|
|||
results = s.createQuery( "from Human where name is not null" ).list();
|
||||
assertEquals( 3, results.size() );
|
||||
String query =
|
||||
getDialect() instanceof DB2Dialect ?
|
||||
( getDialect() instanceof DB2Dialect || getDialect() instanceof HSQLDialect ) ?
|
||||
"from Human where cast(? as string) is null" :
|
||||
"from Human where ? is null"
|
||||
;
|
||||
|
@ -2510,14 +2510,14 @@ public class ASTParserLoadingTest extends FunctionalTestCase {
|
|||
* PostgreSQL >= 8.3.7 typecasts are no longer automatically allowed
|
||||
* <link>http://www.postgresql.org/docs/current/static/release-8-3.html</link>
|
||||
*/
|
||||
if(getDialect() instanceof PostgreSQLDialect){
|
||||
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){
|
||||
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
|
||||
}else{
|
||||
hql = "from Animal a where bit_length(a.bodyWeight) = 24";
|
||||
}
|
||||
|
||||
session.createQuery(hql).list();
|
||||
if(getDialect() instanceof PostgreSQLDialect){
|
||||
if(getDialect() instanceof PostgreSQLDialect || getDialect() instanceof HSQLDialect){
|
||||
hql = "select bit_length(str(a.bodyWeight)) from Animal a";
|
||||
}else{
|
||||
hql = "select bit_length(a.bodyWeight) from Animal a";
|
||||
|
|
|
@ -50,8 +50,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
<property name="intValue"/>
|
||||
<property name="floatValue"/>
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
|
||||
<join table="address">
|
||||
|
@ -73,8 +73,8 @@
|
|||
<property name="login" column="u_login"/>
|
||||
<property name="passwordExpiryDays">
|
||||
<column name="pwd_expiry_weeks"
|
||||
read="pwd_expiry_weeks * 7.0"
|
||||
write="? / 7.0"/>
|
||||
read="pwd_expiry_weeks * 7.0E0"
|
||||
write="? / 7.0E0"/>
|
||||
</property>
|
||||
</join>
|
||||
<join table="t_silly" fetch="select" optional="true">
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
|
||||
<component name="address">
|
||||
|
@ -58,8 +58,8 @@
|
|||
<property name="passwordExpiryDays">
|
||||
<column name="pwd_expiry_weeks"
|
||||
not-null="true"
|
||||
read="pwd_expiry_weeks * 7.0"
|
||||
write="? / 7.0"/>
|
||||
read="pwd_expiry_weeks * 7.0E0"
|
||||
write="? / 7.0E0"/>
|
||||
</property>
|
||||
<many-to-one name="manager"/>
|
||||
</joined-subclass>
|
||||
|
|
|
@ -1940,7 +1940,7 @@ public class FooBarTest extends LegacyTestCase {
|
|||
.addOrder( Order.asc("date") )
|
||||
.list();
|
||||
assertTrue( list.size()==1 && list.get(0)==f );
|
||||
if(!(getDialect() instanceof TimesTenDialect)) {
|
||||
if(!(getDialect() instanceof TimesTenDialect || getDialect() instanceof HSQLDialect)) {
|
||||
list = s.createCriteria(Foo.class).setMaxResults(0).list();
|
||||
assertTrue( list.size()==0 );
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
|
||||
</class>
|
||||
|
@ -62,8 +62,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
|
||||
</class>
|
||||
|
@ -92,7 +92,7 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"/>
|
||||
read="height_centimeters / 2.54E0"/>
|
||||
</property>
|
||||
|
||||
</class>
|
||||
|
|
|
@ -37,8 +37,8 @@
|
|||
<property name="heightInches">
|
||||
<column name="height_centimeters"
|
||||
not-null="true"
|
||||
read="height_centimeters / 2.54"
|
||||
write="? * 2.54"/>
|
||||
read="height_centimeters / 2.54E0"
|
||||
write="? * 2.54E0"/>
|
||||
</property>
|
||||
|
||||
<component name="address">
|
||||
|
@ -56,8 +56,8 @@
|
|||
<property name="passwordExpiryDays">
|
||||
<column name="pwd_expiry_weeks"
|
||||
not-null="true"
|
||||
read="pwd_expiry_weeks * 7.0"
|
||||
write="? / 7.0"/>
|
||||
read="pwd_expiry_weeks * 7.0E0"
|
||||
write="? / 7.0E0"/>
|
||||
</property>
|
||||
<many-to-one name="manager"/>
|
||||
</union-subclass>
|
||||
|
|
|
@ -20,7 +20,6 @@ hibernate.connection.username ${jdbc.user}
|
|||
hibernate.connection.password ${jdbc.pass}
|
||||
hibernate.connection.isolation ${jdbc.isolation}
|
||||
|
||||
|
||||
hibernate.connection.pool_size 5
|
||||
|
||||
hibernate.show_sql true
|
||||
|
|
Loading…
Reference in New Issue