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) {
|
public static void initInternalEvict(CacheAdapter cacheAdapter, AddressAdapter member) {
|
||||||
EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : 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) {
|
public static void sendEvictAllNotification(CacheAdapter cacheAdapter, AddressAdapter member) {
|
||||||
EvictAll eKey = new EvictAll(member == null ? NoAddress.INSTANCE : 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) {
|
public static boolean isEvictAllNotification(Object key) {
|
||||||
|
|
|
@ -36,7 +36,8 @@ public enum FlagAdapter {
|
||||||
CACHE_MODE_LOCAL,
|
CACHE_MODE_LOCAL,
|
||||||
FORCE_ASYNCHRONOUS,
|
FORCE_ASYNCHRONOUS,
|
||||||
FORCE_SYNCHRONOUS,
|
FORCE_SYNCHRONOUS,
|
||||||
SKIP_CACHE_STORE;
|
SKIP_CACHE_STORE,
|
||||||
|
SKIP_CACHE_LOAD;
|
||||||
|
|
||||||
Flag toFlag() {
|
Flag toFlag() {
|
||||||
switch(this) {
|
switch(this) {
|
||||||
|
@ -50,6 +51,8 @@ public enum FlagAdapter {
|
||||||
return Flag.FORCE_SYNCHRONOUS;
|
return Flag.FORCE_SYNCHRONOUS;
|
||||||
case SKIP_CACHE_STORE:
|
case SKIP_CACHE_STORE:
|
||||||
return Flag.SKIP_CACHE_STORE;
|
return Flag.SKIP_CACHE_STORE;
|
||||||
|
case SKIP_CACHE_LOAD:
|
||||||
|
return Flag.SKIP_CACHE_LOAD;
|
||||||
default:
|
default:
|
||||||
throw new CacheException("Unmatched Infinispan flag " + this);
|
throw new CacheException("Unmatched Infinispan flag " + this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -346,9 +346,19 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener
|
||||||
Object propertyFromEntity = persister.getPropertyValue( entity, propertyName, source.getEntityMode() );
|
Object propertyFromEntity = persister.getPropertyValue( entity, propertyName, source.getEntityMode() );
|
||||||
Type propertyType = persister.getPropertyType( propertyName );
|
Type propertyType = persister.getPropertyType( propertyName );
|
||||||
EntityEntry copyEntry = source.getPersistenceContext().getEntry( copy );
|
EntityEntry copyEntry = source.getPersistenceContext().getEntry( copy );
|
||||||
if ( propertyFromCopy == null || ! propertyType.isEntityType() ) {
|
if ( propertyFromCopy == null ||
|
||||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
propertyFromEntity == null ||
|
||||||
"' is null or not an entity; " + propertyName + " =["+propertyFromCopy+"]");
|
! 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 ) ) {
|
if ( isNullabilityCheckedGlobal( source ) ) {
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
@ -358,28 +368,18 @@ public class DefaultMergeEventListener extends AbstractSaveEventListener
|
||||||
saveTransientEntity( copy, entityName, requestedId, source, copyCache, false );
|
saveTransientEntity( copy, entityName, requestedId, source, copyCache, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ! copyCache.containsKey( propertyFromEntity ) ) {
|
if ( log.isTraceEnabled() && propertyFromEntity != null ) {
|
||||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
if ( ( ( EventCache ) copyCache ).isOperatedOn( propertyFromEntity ) ) {
|
||||||
"' from original entity is not in copyCache; " + propertyName + " =["+propertyFromEntity+"]");
|
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
||||||
if ( isNullabilityCheckedGlobal( source ) ) {
|
"' from original entity is in copyCache and is in the process of being merged; " +
|
||||||
throw ex;
|
propertyName + " =["+propertyFromEntity+"]");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// retry save w/o checking non-nullable properties
|
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
||||||
// (the failure will be detected later)
|
"' from original entity is in copyCache and is not in the process of being merged; " +
|
||||||
saveTransientEntity( copy, entityName, requestedId, source, copyCache, false );
|
propertyName + " =["+propertyFromEntity+"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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; " +
|
|
||||||
propertyName + " =["+propertyFromEntity+"]");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.trace( "property '" + copyEntry.getEntityName() + "." + propertyName +
|
|
||||||
"' 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
|
// 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().getEntityName(),
|
||||||
proxy.getHibernateLazyInitializer().getIdentifier()
|
proxy.getHibernateLazyInitializer().getIdentifier()
|
||||||
);
|
);
|
||||||
proxy.getHibernateLazyInitializer().setImplementation( target );
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
finally {
|
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.GeneratedValue;
|
||||||
import javax.persistence.GenerationType;
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.JoinTable;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
public class Classes {
|
public class Classes {
|
||||||
|
|
||||||
@Embeddable
|
@Embeddable
|
||||||
|
@Table(name="Edition")
|
||||||
public static class Edition<T> {
|
public static class Edition<T> {
|
||||||
T name;
|
T name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name="Book")
|
||||||
public static class Book {
|
public static class Book {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||||
|
@ -35,12 +41,15 @@ public class Classes {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Table(name="PopularBook")
|
||||||
public static class PopularBook {
|
public static class PopularBook {
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy=GenerationType.AUTO)
|
@GeneratedValue(strategy=GenerationType.AUTO)
|
||||||
Long id;
|
Long id;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
|
@JoinTable(name="PopularBook_Editions",joinColumns={@JoinColumn(name="PopularBook_id")})
|
||||||
|
|
||||||
Set<Edition<String>> editions = new HashSet<Edition<String>>();
|
Set<Edition<String>> editions = new HashSet<Edition<String>>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,24 +52,24 @@ public class Staff {
|
||||||
@Column(name="size_in_cm")
|
@Column(name="size_in_cm")
|
||||||
@ColumnTransformer(
|
@ColumnTransformer(
|
||||||
forColumn = "size_in_cm",
|
forColumn = "size_in_cm",
|
||||||
read = "size_in_cm / 2.54",
|
read = "size_in_cm / 2.54E0",
|
||||||
write = "? * 2.54" )
|
write = "? * 2.54E0" )
|
||||||
public double getSizeInInches() { return sizeInInches; }
|
public double getSizeInInches() { return sizeInInches; }
|
||||||
public void setSizeInInches(double sizeInInches) { this.sizeInInches = sizeInInches; }
|
public void setSizeInInches(double sizeInInches) { this.sizeInInches = sizeInInches; }
|
||||||
private double sizeInInches;
|
private double sizeInInches;
|
||||||
|
|
||||||
//Weird extra S to avoid potential SQL keywords
|
//Weird extra S to avoid potential SQL keywords
|
||||||
@ColumnTransformer(
|
@ColumnTransformer(
|
||||||
read = "radiusS / 2.54",
|
read = "radiusS / 2.54E0",
|
||||||
write = "? * 2.54" )
|
write = "? * 2.54E0" )
|
||||||
public double getRadiusS() { return radiusS; }
|
public double getRadiusS() { return radiusS; }
|
||||||
public void setRadiusS(double radiusS) { this.radiusS = radiusS; }
|
public void setRadiusS(double radiusS) { this.radiusS = radiusS; }
|
||||||
private double radiusS;
|
private double radiusS;
|
||||||
|
|
||||||
@Column(name="diamet")
|
@Column(name="diamet")
|
||||||
@ColumnTransformer(
|
@ColumnTransformer(
|
||||||
read = "diamet / 2.54",
|
read = "diamet / 2.54E0",
|
||||||
write = "? * 2.54" )
|
write = "? * 2.54E0" )
|
||||||
public double getDiameter() { return diameter; }
|
public double getDiameter() { return diameter; }
|
||||||
public void setDiameter(double diameter) { this.diameter = diameter; }
|
public void setDiameter(double diameter) { this.diameter = diameter; }
|
||||||
private double 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 {
|
try {
|
||||||
s.merge( node );
|
s.merge( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
fail( "should have thrown an exception" );
|
fail( "should have thrown an exception" );
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
checkExceptionFromNullValueForNonNullable(
|
||||||
assertTrue( ex instanceof TransientObjectException );
|
ex,
|
||||||
}
|
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||||
else {
|
false
|
||||||
assertTrue( ex instanceof JDBCException );
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
s.getTransaction().rollback();
|
s.getTransaction().rollback();
|
||||||
|
@ -138,15 +138,15 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.merge( node );
|
s.merge( node );
|
||||||
|
s.getTransaction().commit();
|
||||||
fail( "should have thrown an exception" );
|
fail( "should have thrown an exception" );
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
checkExceptionFromNullValueForNonNullable(
|
||||||
assertTrue( ex instanceof PropertyValueException );
|
ex,
|
||||||
}
|
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||||
else {
|
true
|
||||||
assertTrue( ex instanceof JDBCException );
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
s.getTransaction().rollback();
|
s.getTransaction().rollback();
|
||||||
|
@ -165,15 +165,15 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
s.merge( route );
|
s.merge( route );
|
||||||
|
s.getTransaction().commit();
|
||||||
fail( "should have thrown an exception" );
|
fail( "should have thrown an exception" );
|
||||||
}
|
}
|
||||||
catch ( Exception ex ) {
|
catch ( Exception ex ) {
|
||||||
if ( ( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability() ) {
|
checkExceptionFromNullValueForNonNullable(
|
||||||
assertTrue( ex instanceof PropertyValueException );
|
ex,
|
||||||
}
|
( ( SessionImplementor ) s ).getFactory().getSettings().isCheckNullability(),
|
||||||
else {
|
true
|
||||||
assertTrue( ex instanceof JDBCException );
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
s.getTransaction().rollback();
|
s.getTransaction().rollback();
|
||||||
|
@ -531,6 +531,20 @@ public class MultiPathCircleCascadeTest extends FunctionalTestCase {
|
||||||
assertUpdateCount( 1 );
|
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() {
|
protected void clearCounts() {
|
||||||
getSessions().getStatistics().clear();
|
getSessions().getStatistics().clear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentAddress"
|
<property name="currentAddress"
|
||||||
column="address"
|
column="address"
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
<property name="weightPounds">
|
<property name="weightPounds">
|
||||||
<column name="weight_kg"
|
<column name="weight_kg"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
write="0.453 * ?"
|
write="0.453E0 * ?"
|
||||||
read="weight_kg / 0.453"/>
|
read="weight_kg / 0.453E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<property name="effectiveStartDate" column="eff_start_dt" type="java.util.Date"/>
|
<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();
|
results = s.createQuery( "from Human where name is not null" ).list();
|
||||||
assertEquals( 3, results.size() );
|
assertEquals( 3, results.size() );
|
||||||
String query =
|
String query =
|
||||||
getDialect() instanceof DB2Dialect ?
|
( getDialect() instanceof DB2Dialect || getDialect() instanceof HSQLDialect ) ?
|
||||||
"from Human where cast(? as string) is null" :
|
"from Human where cast(? as string) is null" :
|
||||||
"from Human where ? 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
|
* PostgreSQL >= 8.3.7 typecasts are no longer automatically allowed
|
||||||
* <link>http://www.postgresql.org/docs/current/static/release-8-3.html</link>
|
* <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";
|
hql = "from Animal a where bit_length(str(a.bodyWeight)) = 24";
|
||||||
}else{
|
}else{
|
||||||
hql = "from Animal a where bit_length(a.bodyWeight) = 24";
|
hql = "from Animal a where bit_length(a.bodyWeight) = 24";
|
||||||
}
|
}
|
||||||
|
|
||||||
session.createQuery(hql).list();
|
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";
|
hql = "select bit_length(str(a.bodyWeight)) from Animal a";
|
||||||
}else{
|
}else{
|
||||||
hql = "select bit_length(a.bodyWeight) from Animal a";
|
hql = "select bit_length(a.bodyWeight) from Animal a";
|
||||||
|
|
|
@ -50,8 +50,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="intValue"/>
|
<property name="intValue"/>
|
||||||
<property name="floatValue"/>
|
<property name="floatValue"/>
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<join table="address">
|
<join table="address">
|
||||||
|
@ -73,8 +73,8 @@
|
||||||
<property name="login" column="u_login"/>
|
<property name="login" column="u_login"/>
|
||||||
<property name="passwordExpiryDays">
|
<property name="passwordExpiryDays">
|
||||||
<column name="pwd_expiry_weeks"
|
<column name="pwd_expiry_weeks"
|
||||||
read="pwd_expiry_weeks * 7.0"
|
read="pwd_expiry_weeks * 7.0E0"
|
||||||
write="? / 7.0"/>
|
write="? / 7.0E0"/>
|
||||||
</property>
|
</property>
|
||||||
</join>
|
</join>
|
||||||
<join table="t_silly" fetch="select" optional="true">
|
<join table="t_silly" fetch="select" optional="true">
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<component name="address">
|
<component name="address">
|
||||||
|
@ -58,8 +58,8 @@
|
||||||
<property name="passwordExpiryDays">
|
<property name="passwordExpiryDays">
|
||||||
<column name="pwd_expiry_weeks"
|
<column name="pwd_expiry_weeks"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="pwd_expiry_weeks * 7.0"
|
read="pwd_expiry_weeks * 7.0E0"
|
||||||
write="? / 7.0"/>
|
write="? / 7.0E0"/>
|
||||||
</property>
|
</property>
|
||||||
<many-to-one name="manager"/>
|
<many-to-one name="manager"/>
|
||||||
</joined-subclass>
|
</joined-subclass>
|
||||||
|
|
|
@ -1940,7 +1940,7 @@ public class FooBarTest extends LegacyTestCase {
|
||||||
.addOrder( Order.asc("date") )
|
.addOrder( Order.asc("date") )
|
||||||
.list();
|
.list();
|
||||||
assertTrue( list.size()==1 && list.get(0)==f );
|
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();
|
list = s.createCriteria(Foo.class).setMaxResults(0).list();
|
||||||
assertTrue( list.size()==0 );
|
assertTrue( list.size()==0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
@ -62,8 +62,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"/>
|
read="height_centimeters / 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
</class>
|
</class>
|
||||||
|
|
|
@ -37,8 +37,8 @@
|
||||||
<property name="heightInches">
|
<property name="heightInches">
|
||||||
<column name="height_centimeters"
|
<column name="height_centimeters"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="height_centimeters / 2.54"
|
read="height_centimeters / 2.54E0"
|
||||||
write="? * 2.54"/>
|
write="? * 2.54E0"/>
|
||||||
</property>
|
</property>
|
||||||
|
|
||||||
<component name="address">
|
<component name="address">
|
||||||
|
@ -56,8 +56,8 @@
|
||||||
<property name="passwordExpiryDays">
|
<property name="passwordExpiryDays">
|
||||||
<column name="pwd_expiry_weeks"
|
<column name="pwd_expiry_weeks"
|
||||||
not-null="true"
|
not-null="true"
|
||||||
read="pwd_expiry_weeks * 7.0"
|
read="pwd_expiry_weeks * 7.0E0"
|
||||||
write="? / 7.0"/>
|
write="? / 7.0E0"/>
|
||||||
</property>
|
</property>
|
||||||
<many-to-one name="manager"/>
|
<many-to-one name="manager"/>
|
||||||
</union-subclass>
|
</union-subclass>
|
||||||
|
|
|
@ -20,7 +20,6 @@ hibernate.connection.username ${jdbc.user}
|
||||||
hibernate.connection.password ${jdbc.pass}
|
hibernate.connection.password ${jdbc.pass}
|
||||||
hibernate.connection.isolation ${jdbc.isolation}
|
hibernate.connection.isolation ${jdbc.isolation}
|
||||||
|
|
||||||
|
|
||||||
hibernate.connection.pool_size 5
|
hibernate.connection.pool_size 5
|
||||||
|
|
||||||
hibernate.show_sql true
|
hibernate.show_sql true
|
||||||
|
|
Loading…
Reference in New Issue