forked from playframework/play1
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhibernate-5.2.10-patch-play.patch
More file actions
184 lines (168 loc) · 8.57 KB
/
hibernate-5.2.10-patch-play.patch
File metadata and controls
184 lines (168 loc) · 8.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From 3063617b2d9b1d8210566f974e98694598872f3f Mon Sep 17 00:00:00 2001
From: Alexandre Chatiron <alexandre@payxpert.com>
Date: Thu, 31 Jul 2014 08:47:11 +0800
Subject: [PATCH] patch play 1.3.0 on hibernate 4.2.15
---
.../main/java/org/hibernate/EmptyInterceptor.java | 6 ++--
.../src/main/java/org/hibernate/Interceptor.java | 6 ++--
.../internal/AbstractFlushingEventListener.java | 36 ++++++++++++++++++----
.../test/interfaceproxy/DocumentInterceptor.java | 6 ++--
.../hibernate/test/mixed/DocumentInterceptor.java | 9 ++++--
5 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java b/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
index b3e0dc5..1cd6852 100755
--- a/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
+++ b/hibernate-core/src/main/java/org/hibernate/EmptyInterceptor.java
@@ -111,10 +111,10 @@ public class EmptyInterceptor implements Interceptor, Serializable {
return sql;
}
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {}
+ public boolean onCollectionRemove(Object collection, Serializable key) throws CallbackException { return true; }
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {}
+ public boolean onCollectionRecreate(Object collection, Serializable key) throws CallbackException { return true; }
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {}
+ public boolean onCollectionUpdate(Object collection, Serializable key) throws CallbackException { return true; }
}
\ No newline at end of file
diff --git a/hibernate-core/src/main/java/org/hibernate/Interceptor.java b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
index 7664c36..f935942 100644
--- a/hibernate-core/src/main/java/org/hibernate/Interceptor.java
+++ b/hibernate-core/src/main/java/org/hibernate/Interceptor.java
@@ -132,7 +132,7 @@ public interface Interceptor {
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
+ public boolean onCollectionRecreate(Object collection, Serializable key) throws CallbackException;
/**
* Called before a collection is deleted.
@@ -142,7 +142,7 @@ public interface Interceptor {
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException;
+ public boolean onCollectionRemove(Object collection, Serializable key) throws CallbackException;
/**
* Called before a collection is updated.
@@ -152,7 +152,7 @@ public interface Interceptor {
*
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
*/
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
+ public boolean onCollectionUpdate(Object collection, Serializable key) throws CallbackException;
/**
* Called before a flush
diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java
index 604803a..2bd10a1 100644
--- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java
@@ -152,6 +152,27 @@ public abstract class AbstractFlushingEventListener implements Serializable {
// for ( Map.Entry me : IdentityMap.concurrentEntries( persistenceContext.getEntityEntries() ) ) {
EntityEntry entry = (EntityEntry) me.getValue();
Status status = entry.getStatus();
+
+ // This entity will be saved?
+ boolean willBeSaved = true;
+ try {
+ Object o = me.getKey();
+ Class c = o.getClass();
+ Class jpaBase = Class.forName("play.db.jpa.JPABase");
+ while(!c.equals(Object.class)) {
+ if(c.equals(jpaBase)) {
+ willBeSaved = (Boolean)(jpaBase.getDeclaredField("willBeSaved").get(o));
+ break;
+ }
+ c = c.getSuperclass();
+ }
+ if(!willBeSaved) {
+ continue;
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+
if ( status == Status.MANAGED || status == Status.SAVING || status == Status.READ_ONLY ) {
cascadeOnFlush( session, entry.getPersister(), me.getKey(), anything );
}
@@ -269,8 +290,8 @@ public abstract class AbstractFlushingEventListener implements Serializable {
CollectionEntry ce = me.getValue();
if ( ce.isDorecreate() ) {
- session.getInterceptor().onCollectionRecreate( coll, ce.getCurrentKey() );
- actionQueue.addAction(
+ if(session.getInterceptor().onCollectionRecreate( coll, ce.getCurrentKey() )){
+ actionQueue.addAction(
new CollectionRecreateAction(
coll,
ce.getCurrentPersister(),
@@ -278,10 +299,11 @@ public abstract class AbstractFlushingEventListener implements Serializable {
session
)
);
+ }
}
if ( ce.isDoremove() ) {
- session.getInterceptor().onCollectionRemove( coll, ce.getLoadedKey() );
- actionQueue.addAction(
+ if(session.getInterceptor().onCollectionRemove( coll, ce.getLoadedKey() )){
+ actionQueue.addAction(
new CollectionRemoveAction(
coll,
ce.getLoadedPersister(),
@@ -290,10 +312,11 @@ public abstract class AbstractFlushingEventListener implements Serializable {
session
)
);
+ }
}
if ( ce.isDoupdate() ) {
- session.getInterceptor().onCollectionUpdate( coll, ce.getLoadedKey() );
- actionQueue.addAction(
+ if(session.getInterceptor().onCollectionUpdate( coll, ce.getLoadedKey() )){
+ actionQueue.addAction(
new CollectionUpdateAction(
coll,
ce.getLoadedPersister(),
@@ -302,6 +325,7 @@ public abstract class AbstractFlushingEventListener implements Serializable {
session
)
);
+ }
}
if ( !coll.wasInitialized() && coll.hasQueuedOperations() ) {
actionQueue.addAction(
diff --git a/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/DocumentInterceptor.java b/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/DocumentInterceptor.java
index 3455384..11ec47a 100755
--- a/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/DocumentInterceptor.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/DocumentInterceptor.java
@@ -88,7 +88,7 @@ public class DocumentInterceptor implements Interceptor {
return sql;
}
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {}
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {}
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {}
+ public boolean onCollectionRecreate(Object collection, Serializable key) throws CallbackException { return true;}
+ public boolean onCollectionRemove(Object collection, Serializable key) throws CallbackException { return true;}
+ public boolean onCollectionUpdate(Object collection, Serializable key) throws CallbackException { return true;}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/mixed/DocumentInterceptor.java b/hibernate-core/src/test/java/org/hibernate/test/mixed/DocumentInterceptor.java
index d781826..f3fad5c 100755
--- a/hibernate-core/src/test/java/org/hibernate/test/mixed/DocumentInterceptor.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/mixed/DocumentInterceptor.java
@@ -104,13 +104,16 @@ public class DocumentInterceptor implements Interceptor {
return sql;
}
- public void onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
+ public boolean onCollectionRecreate(Object collection, Serializable key) throws CallbackException {
+ return true;
}
- public void onCollectionRemove(Object collection, Serializable key) throws CallbackException {
+ public boolean onCollectionRemove(Object collection, Serializable key) throws CallbackException {
+ return true;
}
- public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
+ public boolean onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
+ return true;
}
}
--
1.9.2.msysgit.0