Revision 6d2a0540
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/service/CdmFilterablePagingProvider.java | ||
---|---|---|
13 | 13 |
import java.util.List; |
14 | 14 |
|
15 | 15 |
import org.apache.log4j.Logger; |
16 |
import org.hibernate.Session; |
|
16 | 17 |
import org.hibernate.criterion.Criterion; |
17 | 18 |
import org.vaadin.viritin.fields.LazyComboBox.FilterableCountProvider; |
18 | 19 |
import org.vaadin.viritin.fields.LazyComboBox.FilterablePagingProvider; |
... | ... | |
129 | 130 |
|
130 | 131 |
Integer pageIndex = firstRow / pageSize; |
131 | 132 |
Pager<V> page; |
133 |
clearSession(); // clear the session from remains of previous service calls |
|
132 | 134 |
if(!restrictions.isEmpty()){ |
133 | 135 |
List<Restriction<?>> preparedRestrictions = prepareRestrictions(filter, matchMode); |
134 |
page = (Pager<V>) service.findByTitleWithRestrictions(
|
|
136 |
page = service.findByTitleWithRestrictions( |
|
135 | 137 |
type, |
136 | 138 |
filter, |
137 | 139 |
matchMode, |
... | ... | |
142 | 144 |
initStrategy |
143 | 145 |
); |
144 | 146 |
} else { |
145 |
page = (Pager<V>) service.findByTitle(
|
|
147 |
page = service.findByTitle( |
|
146 | 148 |
type, |
147 | 149 |
filter, |
148 | 150 |
matchMode, |
... | ... | |
172 | 174 |
checkNotMixed(); |
173 | 175 |
|
174 | 176 |
Pager<V> page; |
175 |
if(!restrictions.isEmpty()){ |
|
176 | 177 |
|
178 |
clearSession(); // clear the session from remains of previous service calls |
|
179 |
if(!restrictions.isEmpty()){ |
|
177 | 180 |
// Logger.getLogger("org.hibernate.SQL").setLevel(Level.TRACE); |
178 | 181 |
List<Restriction<?>> preparedRestrictions = prepareRestrictions(filter, matchMode); |
179 |
page = (Pager<V>) service.findByTitleWithRestrictions(
|
|
182 |
page = service.findByTitleWithRestrictions( |
|
180 | 183 |
type, |
181 | 184 |
filter, |
182 | 185 |
matchMode, |
... | ... | |
187 | 190 |
null |
188 | 191 |
); |
189 | 192 |
} else { |
190 |
page = (Pager<V>) service.findByTitle(
|
|
193 |
page = service.findByTitle( |
|
191 | 194 |
type, |
192 | 195 |
filter, |
193 | 196 |
matchMode, |
... | ... | |
199 | 202 |
); |
200 | 203 |
} |
201 | 204 |
|
205 |
|
|
202 | 206 |
if(logger.isTraceEnabled()){ |
203 | 207 |
logger.trace("size() - count: " + page.getCount().intValue()); |
204 | 208 |
} |
205 | 209 |
return page.getCount().intValue(); |
206 | 210 |
} |
207 | 211 |
|
212 |
/** |
|
213 |
* |
|
214 |
*/ |
|
215 |
public void clearSession() { |
|
216 |
Session session = service.getSession(); |
|
217 |
if(session.isOpen()){ |
|
218 |
session.clear(); |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
208 | 222 |
/** |
209 | 223 |
* @return |
210 | 224 |
*/ |
Also available in: Unified diff
ref #7559 always clearing session in CdmFilterablePagingProvider