@@ -14,13 +14,10 @@ import org.grails.orm.hibernate.support.HibernateRuntimeUtils
1414import org.grails.datastore.gorm.GormStaticApi
1515import org.grails.datastore.gorm.finders.DynamicFinder
1616import org.grails.datastore.gorm.finders.FinderMethod
17- import org.grails.datastore.mapping.core.Datastore
18- import org.grails.orm.hibernate.support.HibernateVersionSupport
1917import org.hibernate.Criteria
2018import org.hibernate.FlushMode
2119import org.hibernate.Session
2220import org.hibernate.criterion.Example
23- import org.hibernate.criterion.Projections
2421import org.hibernate.criterion.Restrictions
2522import org.hibernate.jpa.QueryHints
2623import org.hibernate.query.NativeQuery
@@ -31,18 +28,16 @@ import org.springframework.transaction.PlatformTransactionManager
3128
3229import javax.persistence.criteria.CriteriaBuilder
3330import javax.persistence.criteria.CriteriaQuery
34- import javax.persistence.criteria.Path
31+ import javax.persistence.criteria.Expression
3532import 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
4641abstract 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