HHH-5490 - dirty data be inserted into 2L cache

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20655 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-09-16 20:23:07 +00:00
parent d587904e98
commit 19300880d6
17 changed files with 613 additions and 27 deletions

View File

@ -75,6 +75,7 @@ public final class EntityIdentityInsertAction extends EntityAction {
//need to do that here rather than in the save event listener to let
//the post insert events to have a id-filled entity when IDENTITY is used (EJB3)
persister.setIdentifier( instance, generatedId, session );
getSession().registerInsertedKey( getPersister(), generatedId );
}

View File

@ -92,7 +92,8 @@ public final class EntityInsertAction extends EntityAction {
}
entry.postUpdate(instance, state, version);
}
getSession().registerInsertedKey( getPersister(), getId() );
}
final SessionFactoryImplementor factory = getSession().getFactory();

View File

@ -365,4 +365,22 @@ public interface SessionImplementor extends Serializable {
* should never be null.
*/
public LoadQueryInfluencers getLoadQueryInfluencers();
/**
* Register keys inserted during the current transaction
*
* @param persister The entity persister
* @param id The id
*/
public void registerInsertedKey(EntityPersister persister, Serializable id);
/**
* Allows callers to check to see if the identified entity was inserted during the current transaction.
*
* @param persister The entity persister
* @param id The id
*
* @return True if inserted during this transaction, false otherwise.
*/
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id);
}

View File

@ -176,16 +176,33 @@ public final class TwoPhaseLoad {
session.getEntityMode(),
session.getFactory()
);
boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
session.getTimestamp(),
version,
useMinimalPuts( session, entityEntry )
);
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
// explicit handling of caching for rows just inserted and then somehow forced to be read
// from the database *within the same transaction*. usually this is done by
// 1) Session#refresh, or
// 2) Session#clear + some form of load
//
// we need to be careful not to clobber the lock here in the cache so that it can be rolled back if need be
if ( session.wasInsertedDuringTransaction( persister, id ) ) {
persister.getCacheAccessStrategy().update(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
version,
version
);
}
else {
boolean put = persister.getCacheAccessStrategy().putFromLoad(
cacheKey,
persister.getCacheEntryStructure().structure( entry ),
session.getTimestamp(),
version,
useMinimalPuts( session, entityEntry )
);
if ( put && factory.getStatistics().isStatisticsEnabled() ) {
factory.getStatisticsImplementor().secondLevelCachePut( persister.getCacheAccessStrategy().getRegion().getName() );
}
}
}

View File

@ -36,6 +36,7 @@ import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@ -597,6 +598,7 @@ public final class SessionImpl extends AbstractSessionImpl
public void afterTransactionCompletion(boolean success, Transaction tx) {
log.trace( "after transaction completion" );
cleanUpInsertedKeysAfterTransaction();
persistenceContext.afterTransactionCompletion();
actionQueue.afterTransactionCompletion(success);
if ( rootSession == null && tx != null ) {
@ -2015,6 +2017,49 @@ public final class SessionImpl extends AbstractSessionImpl
return loadQueryInfluencers;
}
private HashMap<String,List<Serializable>> insertedKeysMap;
/**
* {@inheritDoc}
*/
public void registerInsertedKey(EntityPersister persister, Serializable id) {
// we only are about regsitering these if the persister defines caching
if ( persister.hasCache() ) {
if ( insertedKeysMap == null ) {
insertedKeysMap = new HashMap<String, List<Serializable>>();
}
final String rootEntityName = persister.getRootEntityName();
List<Serializable> insertedEntityIds = insertedKeysMap.get( rootEntityName );
if ( insertedEntityIds == null ) {
insertedEntityIds = new ArrayList<Serializable>();
insertedKeysMap.put( rootEntityName, insertedEntityIds );
}
insertedEntityIds.add( id );
}
}
/**
* {@inheritDoc}
*/
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id) {
// again, we only really care if the entity is cached
if ( persister.hasCache() ) {
if ( insertedKeysMap != null ) {
List<Serializable> insertedEntityIds = insertedKeysMap.get( persister.getRootEntityName() );
if ( insertedEntityIds != null ) {
return insertedEntityIds.contains( id );
}
}
}
return false;
}
private void cleanUpInsertedKeysAfterTransaction() {
if ( insertedKeysMap != null ) {
insertedKeysMap.clear();
}
}
// filter support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/**

View File

@ -660,6 +660,17 @@ public class StatelessSessionImpl extends AbstractSessionImpl
return LoadQueryInfluencers.NONE;
}
public void registerInsertedKey(EntityPersister persister, Serializable id) {
errorIfClosed();
// nothing to do
}
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id) {
errorIfClosed();
// not in any meaning we need to worry about here.
return false;
}
public void setFetchProfile(String name) {}
public void afterTransactionBegin(Transaction tx) {}

View File

@ -77,6 +77,14 @@ public abstract class AbstractDelegateSessionImplementor implements SessionImple
return delegate.getLoadQueryInfluencers();
}
public void registerInsertedKey(EntityPersister persister, Serializable id) {
delegate.registerInsertedKey( persister, id );
}
public boolean wasInsertedDuringTransaction(EntityPersister persister, Serializable id) {
return delegate.wasInsertedDuringTransaction( persister, id );
}
public Interceptor getInterceptor() {
return delegate.getInterceptor();
}

View File

@ -0,0 +1,71 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.cache;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;
/**
* TODO : javadoc
*
* @author Steve Ebersole
*/
@Entity
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "item")
public class CacheableItem {
private Long id;
private String name;
public CacheableItem() {
}
public CacheableItem(String name) {
this.name = name;
}
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,232 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.cache;
import java.util.Map;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
import org.hibernate.test.annotations.TestCase;
/**
* Tests for handling of data just inserted during a transaction being read from the database
* and placed into cache. Initially these cases went through putFromRead which causes problems because it
* loses the context of that data having just been read.
*
* @author Steve Ebersole
*/
public class InsertedDataTest extends TestCase {
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { CacheableItem.class };
}
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CACHE_REGION_PREFIX, "" );
cfg.setProperty( Environment.GENERATE_STATISTICS, "true" );
}
public void testInsert() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.getTransaction().commit();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 1, cacheMap.size() );
s = openSession();
s.beginTransaction();
s.createQuery( "delete CacheableItem" ).executeUpdate();
s.getTransaction().commit();
s.close();
}
public void testInsertWithRollback() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.getTransaction().rollback();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 0, cacheMap.size() );
}
public void testInsertThenUpdate() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
item.setName( "new data" );
s.getTransaction().commit();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 1, cacheMap.size() );
s = openSession();
s.beginTransaction();
s.createQuery( "delete CacheableItem" ).executeUpdate();
s.getTransaction().commit();
s.close();
}
public void testInsertThenUpdateThenRollback() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
item.setName( "new data" );
s.getTransaction().rollback();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 0, cacheMap.size() );
s = openSession();
s.beginTransaction();
s.createQuery( "delete CacheableItem" ).executeUpdate();
s.getTransaction().commit();
s.close();
}
public void testInsertWithRefresh() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.refresh( item );
s.getTransaction().commit();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 1, cacheMap.size() );
s = openSession();
s.beginTransaction();
s.createQuery( "delete CacheableItem" ).executeUpdate();
s.getTransaction().commit();
s.close();
}
public void testInsertWithRefreshThenRollback() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.refresh( item );
s.getTransaction().rollback();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 0, cacheMap.size() );
s = openSession();
s.beginTransaction();
item = (CacheableItem) s.get( CacheableItem.class, item.getId() );
s.getTransaction().commit();
s.close();
assertNull( "it should be null", item );
}
public void testInsertWithClear() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.clear();
s.getTransaction().commit();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 1, cacheMap.size() );
s = openSession();
s.beginTransaction();
s.createQuery( "delete CacheableItem" ).executeUpdate();
s.getTransaction().commit();
s.close();
}
public void testInsertWithClearThenRollback() {
getSessions().getCache().evictEntityRegions();
getSessions().getStatistics().clear();
Session s = openSession();
s.beginTransaction();
CacheableItem item = new CacheableItem( "data" );
s.save( item );
s.flush();
s.clear();
item = (CacheableItem) s.get( CacheableItem.class, item.getId() );
s.getTransaction().rollback();
s.close();
Map cacheMap = getSessions().getStatistics().getSecondLevelCacheStatistics( "item" ).getEntries();
assertEquals( 0, cacheMap.size() );
s = openSession();
s.beginTransaction();
item = (CacheableItem) s.get( CacheableItem.class, item.getId() );
s.getTransaction().commit();
s.close();
assertNull( "it should be null", item );
}
}

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.complete;

View File

@ -1,10 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.complete;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
@ -26,6 +48,8 @@ public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
}
public void testComponentPropertyRef() {
Session s = openSession();
s.beginTransaction();
Person p = new Person();
p.setIdentity( new Identity() );
Account a = new Account();
@ -33,13 +57,13 @@ public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
a.setOwner(p);
p.getIdentity().setName("Gavin");
p.getIdentity().setSsn("123-12-1234");
Session s = openSession();
Transaction tx = s.beginTransaction();
s.persist(p);
s.persist(a);
s.flush();
s.clear();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
assertNotNull( a.getOwner() );
@ -65,7 +89,7 @@ public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
s.delete( a );
s.delete( a.getOwner() );
tx.commit();
s.getTransaction().commit();
s.close();
}
}

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.complete;
import java.io.Serializable;

View File

@ -1,3 +1,26 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.complete;

View File

@ -1,4 +1,26 @@
//$Id: Account.java 7587 2005-07-21 01:22:38Z oneovthafew $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.partial;
public class Account {

View File

@ -1,4 +1,26 @@
//$Id: Identity.java 7587 2005-07-21 01:22:38Z oneovthafew $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.partial;
public class Identity {

View File

@ -1,11 +1,32 @@
//$Id: PartialComponentPropertyRefTest.java 9914 2006-05-09 09:37:18Z max.andersen@jboss.com $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.partial;
import junit.framework.Test;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.testing.junit.functional.FunctionalTestCase;
import org.hibernate.testing.junit.functional.FunctionalTestClassTestSuite;
@ -27,6 +48,8 @@ public class PartialComponentPropertyRefTest extends FunctionalTestCase {
}
public void testComponentPropertyRef() {
Session s = openSession();
s.beginTransaction();
Person p = new Person();
p.setIdentity( new Identity() );
Account a = new Account();
@ -34,13 +57,13 @@ public class PartialComponentPropertyRefTest extends FunctionalTestCase {
a.setOwner(p);
p.getIdentity().setName("Gavin");
p.getIdentity().setSsn("123-12-1234");
Session s = openSession();
Transaction tx = s.beginTransaction();
s.persist(p);
s.persist(a);
s.flush();
s.clear();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
assertTrue( Hibernate.isInitialized( a.getOwner() ) );
assertNotNull( a.getOwner() );
@ -66,7 +89,7 @@ public class PartialComponentPropertyRefTest extends FunctionalTestCase {
s.delete( a );
s.delete( a.getOwner() );
tx.commit();
s.getTransaction().commit();
s.close();
}
}

View File

@ -1,4 +1,26 @@
//$Id: Person.java 7587 2005-07-21 01:22:38Z oneovthafew $
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. 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 Inc.
*
* 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.propertyref.component.partial;
public class Person {