Skip to content

Commit f044d2e

Browse files
committed
GRAILS-10024 also need AggregatePersistenceContextInterceptor to implement ParticipatingInterceptor
1 parent 177cd42 commit f044d2e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

grails-hibernate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/support/AggregatePersistenceContextInterceptor.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020

2121
import org.codehaus.groovy.grails.commons.GrailsDomainClassProperty;
22+
import org.codehaus.groovy.grails.support.ParticipatingInterceptor;
2223
import org.codehaus.groovy.grails.support.PersistenceContextInterceptor;
2324
import org.hibernate.SessionFactory;
2425
import org.springframework.beans.factory.InitializingBean;
@@ -28,7 +29,7 @@
2829
/**
2930
* @author Burt Beckwith
3031
*/
31-
public class AggregatePersistenceContextInterceptor implements PersistenceContextInterceptor, InitializingBean, ApplicationContextAware {
32+
public class AggregatePersistenceContextInterceptor implements ParticipatingInterceptor, InitializingBean, ApplicationContextAware {
3233

3334
private List<PersistenceContextInterceptor> interceptors = new ArrayList<PersistenceContextInterceptor>();
3435
private List<String> dataSourceNames = new ArrayList<String>();
@@ -94,6 +95,26 @@ public void setReadWrite() {
9495
}
9596
}
9697

98+
public void setParticipate(boolean flag) {
99+
for (PersistenceContextInterceptor interceptor : interceptors) {
100+
if (interceptor instanceof ParticipatingInterceptor) {
101+
((ParticipatingInterceptor)interceptor).setParticipate(flag);
102+
}
103+
}
104+
}
105+
106+
public boolean getParticipate() {
107+
for (PersistenceContextInterceptor interceptor : interceptors) {
108+
if (interceptor instanceof ParticipatingInterceptor) {
109+
if (((ParticipatingInterceptor)interceptor).getParticipate()) {
110+
// true at least one is true
111+
return true;
112+
}
113+
}
114+
}
115+
return false;
116+
}
117+
97118
/**
98119
* Dependency injection for the datasource names.
99120
* @param names the names

0 commit comments

Comments
 (0)