groovy « Field « JPA Q&A

1. how to define if domain has more than one unique field in grails?

I have domain that has more than one unique fields like the following

class Shoes{
   String name; 
   Brand brand ;
   Color color ;

2. Sorting on multiple fields with criteria in Grails

I have the following query which id like to sorty by "raceDate" and by "raceNo" asc. I can figure out how to sort by one field, but not by two, any ...

3. Grails domain class query - how can I find by fields that link to another domain class?

Lets say I have two domain classes:

class User {
  String name
  Role role

class Role {
  String name
  static belongsTo = [user: User]
and I create some records:
def r1 ...

4. Quering computed fields in GORM

I am trying to query the following HQL using GORM:

MailMessage.executeQuery("toId, count(toId) from (SELECT  toId, threadId FROM MailMessage as m WHERE receiveStatus = 'u' GROUP BY threadId, toId) as x group ...

5. Grails dynamic finder where field name contains reserved words

So I have a grails domain class:

class Message
    Inbox inbox
    Boolean hasBeenLogicallyDeletedByRecipient

    static belongsTo = [

6. Add dateCreated field to join table in Grails

I have a M:M relationship between User and Badge which creates a join table called "user_badges". This table has the fields: user_id and badge_id. Is there a way to get the ...

7. Grails - cascading save through class field

Not exactly a good explanation in the title, so let's try to do it better: I have two classes like this:

Class A {
  B bObject

Class B {

static belongsTo = [a: A]
and ...

8. Dynamic model or custom fields thanks to Groovy

Hi, I've been working some time with Hibernate and came to the need of flexibility among some objects, for which some fields are only known at runtime. Therefore I needed a way for Hibernate to persist beans that did not exist at compile time, and which definition is read from a configuration file. I've found some way using the dynamic language ...