The easiest way to perform database queries is through dynamic finders. Check my previous post for a tutorial on this topic. It may not be suitable for complex requirements and cases where the developer needs a lower level of control.HQL is a very good alternative as it is very similar to SQL.This method returns the number of objects that is changed by to call this method. /** * */ package roseindia; import javax.persistence. Each item is a list that corresponds to the value as enumerated in the select clause.The code can also be written like this to help visualize the data structure: This will print all ages found in the table and how many people have that age, provided that there are more than 1 person in the age group. Here is a code sample on how to do that: def list Page1 = Person.execute Query("from Person order by id", [offset:0, max:10]) def list Page2 = Person.execute Query("from Person order by id", [offset:10, max:10]) def list Page3 = Person.execute Query("from Person order by id", [offset:20, max:10]) GORM/Hibernate will translate the paging information to it's proper SQL syntax depending on the database.
When the select clause is explicitly used, HQL will not return a list of domain objects. Here is an example assuming that at least 1 record is in the database: def list = Person.execute Query("select first Name, last Name from Person") def first Person = list def first Name = first Person def last Name = first Person println "First Name = $" println "Last Name = $" The variable list will be assigned a list of items.Hibernate is used as the underlying technology for the object-relational mapping of Grails (GORM). It means that since Grails is based on it, we could write applications that is compatible with most popular databases.We don't need to write different queries for each possible database.In this section, we will learn how to use execute Update() method in your JPA application. To use execute Update() method in your jpa application for executing a jpa UPDATE/DELETE query.
Your error messages should show up in one of the Tomcat logs.