Author: gbadner
Date: 2010-02-23 19:11:24 -0500 (Tue, 23 Feb 2010)
New Revision: 18866
Modified:
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ImmutableTest.java
Log:
HHH-4948 : Session.flush() does not always cascade save or update to read-only or
immutable entities
Modified:
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java 2010-02-23
23:55:06 UTC (rev 18865)
+++
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultAutoFlushEventListener.java 2010-02-24
00:11:24 UTC (rev 18866)
@@ -92,7 +92,8 @@
private boolean flushMightBeNeeded(final EventSource source) {
return !source.getFlushMode().lessThan(FlushMode.AUTO) &&
source.getDontFlushFromFind() == 0 &&
- source.getPersistenceContext().hasNonReadOnlyEntities();
+ ( source.getPersistenceContext().getEntityEntries().size() > 0 ||
+ source.getPersistenceContext().getCollectionEntries().size() > 0 );
}
}
Modified:
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java
===================================================================
---
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java 2010-02-23
23:55:06 UTC (rev 18865)
+++
core/trunk/core/src/main/java/org/hibernate/event/def/DefaultFlushEventListener.java 2010-02-24
00:11:24 UTC (rev 18866)
@@ -44,8 +44,9 @@
*/
public void onFlush(FlushEvent event) throws HibernateException {
final EventSource source = event.getSession();
- if ( source.getPersistenceContext().hasNonReadOnlyEntities() ) {
-
+ if ( source.getPersistenceContext().getEntityEntries().size() > 0 ||
+ source.getPersistenceContext().getCollectionEntries().size() > 0 ) {
+
flushEverythingToExecutions(event);
performExecutions(source);
postFlush(source);
@@ -53,7 +54,7 @@
if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
source.getFactory().getStatisticsImplementor().flush();
}
-
+
}
}
}
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ImmutableTest.java
===================================================================
---
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ImmutableTest.java 2010-02-23
23:55:06 UTC (rev 18865)
+++
core/trunk/testsuite/src/test/java/org/hibernate/test/immutable/ImmutableTest.java 2010-02-24
00:11:24 UTC (rev 18866)
@@ -280,7 +280,6 @@
// c was loaded into s, so it should be read-only
assertTrue( s.isReadOnly( c ) );
c.setCustomerName("foo bar");
- c.getVariations().add( new ContractVariation(3, c) );
cv1 = (ContractVariation) c.getVariations().iterator().next();
cv1.setText("blah blah");
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
@@ -350,7 +349,6 @@
// c was loaded into s, so it should be read-only
assertTrue( s.isReadOnly( c ) );
c.setCustomerName("foo bar");
- c.getVariations().add( new ContractVariation(3, c) );
cv1 = (ContractVariation) c.getVariations().iterator().next();
cv1.setText("blah blah");
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
Show replies by date