Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 2e254db

Browse files
committed
Workaround GROOVY-9460
1 parent 3842490 commit 2e254db

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

grails-datastore-gorm-hibernate5/src/main/groovy/org/grails/orm/hibernate/AbstractHibernateGormStaticApi.groovy

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ import org.grails.orm.hibernate.support.HibernateRuntimeUtils
1414
import org.grails.datastore.gorm.GormStaticApi
1515
import org.grails.datastore.gorm.finders.DynamicFinder
1616
import org.grails.datastore.gorm.finders.FinderMethod
17-
import org.grails.datastore.mapping.core.Datastore
18-
import org.grails.orm.hibernate.support.HibernateVersionSupport
1917
import org.hibernate.Criteria
2018
import org.hibernate.FlushMode
2119
import org.hibernate.Session
2220
import org.hibernate.criterion.Example
23-
import org.hibernate.criterion.Projections
2421
import org.hibernate.criterion.Restrictions
2522
import org.hibernate.jpa.QueryHints
2623
import org.hibernate.query.NativeQuery
@@ -31,18 +28,16 @@ import org.springframework.transaction.PlatformTransactionManager
3128

3229
import javax.persistence.criteria.CriteriaBuilder
3330
import javax.persistence.criteria.CriteriaQuery
34-
import javax.persistence.criteria.Path
31+
import javax.persistence.criteria.Expression
3532
import javax.persistence.criteria.Root
36-
import java.util.regex.Pattern
3733

3834
/**
3935
* Abstract implementation of the Hibernate static API for GORM, providing String-based method implementations
4036
*
4137
* @author Graeme Rocher
4238
* @since 4.0
4339
*/
44-
//TODO: Re-enable once the Groovy bug is fixed.
45-
//@CompileStatic
40+
@CompileStatic
4641
abstract class AbstractHibernateGormStaticApi<D> extends GormStaticApi<D> {
4742

4843
protected ProxyHandler proxyHandler
@@ -110,7 +105,8 @@ abstract class AbstractHibernateGormStaticApi<D> extends GormStaticApi<D> {
110105
CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(persistentEntity.javaClass)
111106
Root queryRoot = criteriaQuery.from(persistentEntity.javaClass)
112107
criteriaQuery = criteriaQuery.where (
113-
criteriaBuilder.equal(queryRoot.get(persistentEntity.identity.name), id)
108+
//TODO: Remove explicit type cast once GROOVY-9460
109+
criteriaBuilder.equal((Expression<?>) queryRoot.get(persistentEntity.identity.name), id)
114110
)
115111
Query criteria = session.createQuery(criteriaQuery)
116112
HibernateHqlQuery hibernateHqlQuery = new HibernateHqlQuery(
@@ -144,7 +140,8 @@ abstract class AbstractHibernateGormStaticApi<D> extends GormStaticApi<D> {
144140

145141
Root queryRoot = criteriaQuery.from(persistentEntity.javaClass)
146142
criteriaQuery = criteriaQuery.where (
147-
criteriaBuilder.equal(queryRoot.get(persistentEntity.identity.name), id)
143+
//TODO: Remove explicit type cast once GROOVY-9460
144+
criteriaBuilder.equal((Expression<?>) queryRoot.get(persistentEntity.identity.name), id)
148145
)
149146
Query criteria = session.createQuery(criteriaQuery)
150147
.setHint(QueryHints.HINT_READONLY, true)
@@ -225,7 +222,8 @@ abstract class AbstractHibernateGormStaticApi<D> extends GormStaticApi<D> {
225222
Root queryRoot = criteriaQuery.from(persistentEntity.javaClass)
226223
def idProp = queryRoot.get(persistentEntity.identity.name)
227224
criteriaQuery = criteriaQuery.where (
228-
criteriaBuilder.equal(idProp, id)
225+
//TODO: Remove explicit type cast once GROOVY-9460
226+
criteriaBuilder.equal((Expression<?>) idProp, id)
229227
)
230228
criteriaQuery.select(criteriaBuilder.count(criteriaQuery.from(persistentEntity.javaClass)))
231229
Query criteria = session.createQuery(criteriaQuery)

0 commit comments

Comments
 (0)