grails.orm.hibernate.HibernateEntity.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grace-datastore-gorm-hibernate Show documentation
Show all versions of grace-datastore-gorm-hibernate Show documentation
Grace Data : Grace Datastore Gorm Hibernate
package grails.gorm.hibernate
import groovy.transform.CompileStatic
import org.grails.datastore.gorm.GormEnhancer
import org.grails.datastore.gorm.GormEntity
import org.grails.orm.hibernate.AbstractHibernateGormStaticApi
/**
* Extends the {@link GormEntity} trait adding additional Hibernate specific methods
*
* @author Graeme Rocher
* @since 6.1
*/
@CompileStatic
trait HibernateEntity extends GormEntity {
/**
* Finds all objects for the given string-based query
*
* @param sql The query
*
* @return The object
*/
static List findAllWithSql(CharSequence sql) {
currentHibernateStaticApi().findAllWithSql sql, Collections.emptyMap()
}
/**
* Finds an entity for the given SQL query
*
* @param sql The sql query
* @return The entity
*/
static D findWithSql(CharSequence sql) {
currentHibernateStaticApi().findWithSql(sql, Collections.emptyMap())
}
/**
* Finds all objects for the given string-based query
*
* @param sql The query
*
* @return The object
*/
static List findAllWithSql(CharSequence sql, Map args) {
currentHibernateStaticApi().findAllWithSql sql, args
}
/**
* Finds an entity for the given SQL query
*
* @param sql The sql query
* @return The entity
*/
static D findWithSql(CharSequence sql, Map args) {
currentHibernateStaticApi().findWithSql(sql, args)
}
private static AbstractHibernateGormStaticApi currentHibernateStaticApi() {
(AbstractHibernateGormStaticApi) GormEnhancer.findStaticApi(this)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy