Skip to content

Commit b9b84ed

Browse files
author
Adam Collins
committed
#265 fix for intersect/batch when internal caches are empty
1 parent 2d6644c commit b9b84ed

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

grails-app/services/au/org/ala/spatial/FieldService.groovy

+15-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import groovy.sql.Sql
2020
import org.codehaus.jackson.map.DeserializationConfig
2121
import org.codehaus.jackson.map.ObjectMapper
2222
import org.postgresql.core.Field
23+
import org.springframework.transaction.support.TransactionSynchronizationManager
2324

2425
import java.sql.ResultSet
2526

@@ -269,10 +270,21 @@ class FieldService {
269270
}
270271

271272
List<Fields> getFields(boolean includeAdmin = false) {
272-
if (includeAdmin) {
273-
Fields.findAll()
273+
// wrap in a transaction if it is not already, unsure why this is necessary for some instances
274+
if (TransactionSynchronizationManager.isActualTransactionActive()) {
275+
if (includeAdmin) {
276+
Fields.findAll()
277+
} else {
278+
Fields.findAllByEnabled(true)
279+
}
274280
} else {
275-
Fields.findAllByEnabled(true)
281+
Fields.withTransaction {
282+
if (includeAdmin) {
283+
Fields.findAll()
284+
} else {
285+
Fields.findAllByEnabled(true)
286+
}
287+
}
276288
}
277289
}
278290

0 commit comments

Comments
 (0)