gorm « Query « JPA Q&A





1. Limiting no of outputs in Hibernate query    stackoverflow.com

I have a hibernate query in grails

 Book.findAllByRating(4)
In the above query i want only 5 number of outputs.How do I limit the output to 5?

2. Grails query association problem    stackoverflow.com

I'm having trouble writing a query for the following domain classes:

class Person {
  static hasMany = [memberships: Membership]
}

class Membership {

    static belongsTo = [person: Person, group: Group]

 ...

3. GORM Hibernate query    stackoverflow.com

I have the following Grails domain objects

class ProductType {
    String name
    static hasMany = [attributes: Attribute]
}

class Attribute {

    Boolean mandatory = false
 ...

4. Accessing the join table in a hql query for a many-to-many relationship in grails    stackoverflow.com

I have 2 domain classes with a many-to-many relationship in grails: decks and cards. The setup looks like this:

class Deck {
static hasMany = [cards: Card]
}

class Card {
static hasMany = [decks: Deck]
static belongsTo ...

5. Query the other way across a one-to-many with Criteria Builder    stackoverflow.com

Lets say I have the following one-to-many relationship:

Site has many Users
User belongs to one Site
I've setup the relationship like this
class Site {
    static hasMany = [users:User]
   ...

6. Grails: Help with HQL query    stackoverflow.com

I'm not very good in SQL and HQL... I have two domains:

class Hotel {
 String name
}

class Room {
 Hotel hotel
 float price
}
How many hotels have at least one room ?

7. Grails GORM (Hibernate) query    stackoverflow.com

I'm trying to do the below sql statement in GORM

select * from table1 where table1.x not in
      (select x from table 2 where y='something');
so, I have ...

8. How to implement "select sum()" in Grails    stackoverflow.com

I have a relationship like this:

class E {
  string name
  hasMany = [me:ME]
}

class M {
  float price
}

class ME {
 E e
 M m
 int quantity
}
And I'd hate to ...

9. Querying on property of a hasMany relationship    stackoverflow.com

I have the following association in a domain I'm working on (not actually pirates unfortunately). A ship has many pirates. I want to be able to find all ships ...





10. Query Subset of Columns with Gorm    stackoverflow.com

Suppose I have the following Domain class:

class Book {
  String title
  String author
  byte[] largeCoverArtImage
}
I have a list view where I do not need to display largeCoverArtImage, how ...

11. How to execute BACKUP DATABASE query from grails?    stackoverflow.com

I want to backup HSQLDB from grails, Here's the command BACKUP DATABASE TO 'C:/BACKUP/' BLOCKING But how to do this in GORM where all seems Entity related even executeQuery ? Thank you for sharing your ...

12. Grails: Querying Associations causes groovy.lang.MissingMethodException    stackoverflow.com

I've got an issue with Grails where I have a test app with:

class Artist {
static constraints = {
 name()
}

 static hasMany = [albums:Album]
 String name
}

class Album {
 static constraints = {
 ...

13. delete all items from sorted set in grails    stackoverflow.com

I have a grails project with a class that I can delete no problem when doing it "manually" from the controller. I use the following code.

def delete = {
   ...

14. How can I refer to the "this" object in a Grails criteria query    stackoverflow.com

I have a set of domain objects that are related like this:

class Book {
    static belongsTo = [author: Author]
}

class Contract {
    static belongsTo = [author: ...

15. how to get distinct results using Projections and Criteria    stackoverflow.com

I am trying to load distinct Parents using Criteria in Grails. The query is as following Query:

def criteria = Parent.createCriteria();
       ...

16. find objects by many parameters    stackoverflow.com

I have rather big form where a user can choose any number of parameters (from 1 to 10). Example:

  1. Cities - NYC, LA ; age - 18
  2. Cities - null (nothing was chosen) ...





17. gorm save method causing a select query to fire    stackoverflow.com

I am using grails 1.3.7 and zkoss and my domain model is as below, I load the Person entity in session 1 and make changes to it through the UI. The on ...

18. Hibernate Query Escaping (from Grails' GORM) - again    stackoverflow.com

I have seen many related question, but none of them is exactly my problem. General question: where exactly is specified how the things get escaped in Hibernate, in particular for Grails GORM? Particular ...

19. Grails GORM - How to get a PagedResultList when using aggregation functions    stackoverflow.com

I'm using GORM from grails 1.2.1. No chance of upgrading at this point. This is not a grails app per se; rather it is a webapp that uses groovy and leverages ...

20. Grails Order By Not Working    stackoverflow.com

I have a Grails query that has an order by clause, but when the results come back they are not ordered by that field. If I run the same query in ...

21. Grails (Hibernate) does select before insert without passing id argument value    stackoverflow.com

I'm starting more serious tests of my grails web-app and it was time to move from hsqldb to postgres. Everything went more or less ok, however I'm getting an error in ...

22. How to get count of all items in a criteria GORM query    stackoverflow.com

So i have this criteria query that is getting 10 feature articles that have itemchannel objects that are of type 4 and in a channel of id 1 i.e get me ...