HHH-4948 : Session.flush() does not always cascade save or update to read-only or immutable entities
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18866 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
003658834d
commit
863f6a8fb7
|
@ -92,7 +92,8 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
||||||
private boolean flushMightBeNeeded(final EventSource source) {
|
private boolean flushMightBeNeeded(final EventSource source) {
|
||||||
return !source.getFlushMode().lessThan(FlushMode.AUTO) &&
|
return !source.getFlushMode().lessThan(FlushMode.AUTO) &&
|
||||||
source.getDontFlushFromFind() == 0 &&
|
source.getDontFlushFromFind() == 0 &&
|
||||||
source.getPersistenceContext().hasNonReadOnlyEntities();
|
( source.getPersistenceContext().getEntityEntries().size() > 0 ||
|
||||||
|
source.getPersistenceContext().getCollectionEntries().size() > 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
|
||||||
*/
|
*/
|
||||||
public void onFlush(FlushEvent event) throws HibernateException {
|
public void onFlush(FlushEvent event) throws HibernateException {
|
||||||
final EventSource source = event.getSession();
|
final EventSource source = event.getSession();
|
||||||
if ( source.getPersistenceContext().hasNonReadOnlyEntities() ) {
|
if ( source.getPersistenceContext().getEntityEntries().size() > 0 ||
|
||||||
|
source.getPersistenceContext().getCollectionEntries().size() > 0 ) {
|
||||||
|
|
||||||
flushEverythingToExecutions(event);
|
flushEverythingToExecutions(event);
|
||||||
performExecutions(source);
|
performExecutions(source);
|
||||||
|
|
|
@ -280,7 +280,6 @@ public class ImmutableTest extends FunctionalTestCase {
|
||||||
// c was loaded into s, so it should be read-only
|
// c was loaded into s, so it should be read-only
|
||||||
assertTrue( s.isReadOnly( c ) );
|
assertTrue( s.isReadOnly( c ) );
|
||||||
c.setCustomerName("foo bar");
|
c.setCustomerName("foo bar");
|
||||||
c.getVariations().add( new ContractVariation(3, c) );
|
|
||||||
cv1 = (ContractVariation) c.getVariations().iterator().next();
|
cv1 = (ContractVariation) c.getVariations().iterator().next();
|
||||||
cv1.setText("blah blah");
|
cv1.setText("blah blah");
|
||||||
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
|
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
|
||||||
|
@ -350,7 +349,6 @@ public class ImmutableTest extends FunctionalTestCase {
|
||||||
// c was loaded into s, so it should be read-only
|
// c was loaded into s, so it should be read-only
|
||||||
assertTrue( s.isReadOnly( c ) );
|
assertTrue( s.isReadOnly( c ) );
|
||||||
c.setCustomerName("foo bar");
|
c.setCustomerName("foo bar");
|
||||||
c.getVariations().add( new ContractVariation(3, c) );
|
|
||||||
cv1 = (ContractVariation) c.getVariations().iterator().next();
|
cv1 = (ContractVariation) c.getVariations().iterator().next();
|
||||||
cv1.setText("blah blah");
|
cv1.setText("blah blah");
|
||||||
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
|
// cv1 and cv2 were loaded into s by hibernate, so they should be read-only
|
||||||
|
|
Loading…
Reference in New Issue