gorm

Grails/GORM Legacy DB One-to-Many mappedBy issue

I have a legacy DB with rather simple structure. I have "rolls" that contain "rollTotals". Roll has a primary key of "rollID" and RollTotals have a composite key on "rollID" and "category". So in Grails, I have: class Roll { Integer id ... static hasMany = [ rollTotals: RollTotal ] static mapping = { table('roll...

Querying on property of a hasMany relationship

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 that have a captain and do not have any land lubbers on the crew. class Pirate { String name Rank rank enum Rank { CAPTAIN, DECK_HAND, LAND_LUBBER } } cl...

Lazy fetching of objects using FindAllBy , for the first time

Hello, When I use criteria queries, the result contains array list of lazy initialized objects. that is, the list has values with handler org.codehaus.groovy.grails.orm.hibernate.proxy.GroovyAwareJavassistLazyInitializer. This prevent me from doing any array operation (minus, remove etc) in it. When I use, GORM meth...

Why do I get a "Null value was assigned to a property of primitive type setter of" error message when using HibernateCriteriaBuilder in Grails

I get the following error when using a primitive attribute in my grails domain object: Null value was assigned to a property of primitive type setter of MyDomain.myAttribute org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of MyDomain.myAttribute at grails.orm.HibernateCriteriaBuilde...

Query Subset of Columns with Gorm

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 can I perform the following SQL query using GORM Criteria? select title, author from Book ...

DB column order creation in Grails

Hi, I have this domain class: class Requestmap { String url String configAttribute static constraints = { url(blank: false, unique: true) configAttribute(blank: false) } } Its DB Table corresponds to Column | Type | Modifiers ------------------+------------------------+----...

How to filter a particular class when i have a inheritance ?

Hi, I have this code : class A { String name } class B extends A{ } class C extends A{ } class D{ A a } D d = new D(); d.a = new B() D d2 = new D(); d.a = new C() My query : D.createCriteria().list(...){ A{ eq "a","test" } } But in my result I would have only the element matching with B class not C class. Is it p...

Grails Delete and Cascading

I have the following 3 classes class User { static hasMany = [coupons: Coupon] } class Coupon { static belongsTo = [affiliate: Affiliate] } class Affiliate { static hasMany = [coupons: Coupon] } How do I setup cascading so that I can delete a specific Coupon and it will be removed from the lists in Affiliate and User. I keep gett...

Is there a 'not in' equivalent in GORM?

Is this possible to convert in createCriteria()? SELECT * FROM node WHERE (node.type = 'act' AND nid NOT IN (SELECT nid FROM snbr_act_community)) LIMIT 10 I know there's a 'in' operator and here's what I have so far: def c = VolunteerOpportunity.createCriteria() def matchingActs = c.list { node { eq('type', 'act') } ...

one to many relation on appengine with Grails/GORM

Hi, does anyone know how to handle a "one to many" relationship with Grails/GORM on the google appengine? I do understand how relationships get handled with Gorm, and there is also a good series of articles about it: http://blog.springsource.com/2010/06/23/gorm-gotchas-part-1/ http://blog.springsource.com/2010/07/02/gorm-gotchas-part-...

uniqueness of composite id with null component

Hi, I am running into problems using unique constraints. The following combinations are allowed A.name B.name foo NULL foo bar foo bar1 foo1 bar It should not be possible to create a new A with same name, only if it has a different B. With the constraints below it is possible to create A.name B.name foo NULL foo ...

Many-to-Many of members of the same domain class

In Grails, I like to have a many-to-many relation among entries of the same domain class Person. Relations will link to different persons the "leftPerson" and the "rightPerson" since the "Parent-child" and "Employer-Employee" relations will discriminate the position of each link. That I would like to have is something like the following...

How to I bind a Hibernate Session to a thread in Grails?

I'm writing a multi-threaded application in Grails and the additional threads need access to GORM/Hibernate. When they try to access GORM I get the error "org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here". OK fair enough, can someone guide me ...

Grails withCriteria exception when using One-to-many relationship

I have 2 domains : class JobProcess { static constraints = { scriptUser(blank:false) scriptType() scriptName() scriptPath() scriptArgs(size:0..1000,nullable:true) scriptDateCreated(nullable:true) scriptDateStarted(nullable:true) scriptDateFinished(nullable:true) script...

Can domain classes be configured to insert a new record instead of updating when saved?

When I change a domain object, rather than updating the database record, I'd like to archive the old record record and create a new one. I'd like to force GORM to do this automatically. For example, if I had this domain class: class User { String username String email Boolean active } then I'd like user.email = email us...

GNUstep - Can GORM open Interface Builder-created NIB files or not?

I have created a working project in XCode + Interface Builder on my iMac. I would like to port it to my Windows XP machine, which has GNUStep installed (and it seems to work okay as long as I create programs from scratch on there). I have transferred all the files to my Windows machine, created a new project in ProjectCenter and compiled...

Sorting query results according to parent property in grails

Is it possible in grails to sort query results according to a property of a parent class in a relationship. E.g. I have a user domain class which has a one to many relationship with a list of Tasks. When showing the list page of the Tasks domain class, I want to be able to sort the list of tasks by the associated User name. class User ...

How to execute BACKUP DATABASE query from grails ?

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 experience :) ...

In Grails, setting tablePerHierarchy false doesn't create a foreign key relationship

We have our base class as something like package com.ids.emr.diag class Base { String foo static mapping = { tablePerHierarchy false } } and the subclass as class Sub extends Base { String bar } This does not create a foreign key relationship between the base class and the subclass. Is there anything wrong that we're do...

MSSQL's varchar(n) equivalent in GORM

I would like to know if it's possible to set the size of VARCHAR column if database is MS SQL 2005. Here's my domain: class UpdateTable { static mapping = { table 'UpdateTable' id column: 'UpdateFileId', generator: 'increment' version false fileName column: 'FileName', size: 50 } String file...