grails

How do hasMany and hasOne work in Grails?

Hi, I am having problems defining one-to-one and one-to-many relationships with domain classes. I have the following domain classes class Team { static hasMany = [players: Player] static hasOne = [coach: Coach] } class Person { String name } class Player extends Person { } class Coach extends Person { } So my question...

Eager fetching of an object

I am Serializing an object which has a deep hierarchy of objects. After deserialization, i am able to access only those fields which were available in object before serialization. For rest, i get LazyInitializationException. class A { List<B> objs } class B { C c } class C { D d } Initially, i used to get LazyInitiali...

Grails form data binding when another domain object is referenced in the form

How do I get Grails data binding to correctly bind referenced objects (such as Country in the example below)? Given the following two Grails domain classes .. class User { String username Country country } class Country { String name } .. and the following HTML form .. <g:form> <g:textField name="user.username" value="${user...

What are Groovy/Grails/Hibernate/JBoss/Jade in very simple terms?

I am new to Java. Its only been six months but I do understand Java. While reading about it sometimes, I come across these terms - Groovy, Grails, Hibernate, JBoss, Jade and many more. I know I can read all about them individually. But can somebody give me a treetop view of what is happening here? What is all this? We have Java and th...

How can I return a 404/50x status code from a Grails Controller?

I have a controller that needs to return a 404 page and status code on certain conditions. I can't seem to find out how to do this in Grails. A coworker recommended this method: response.sendError(HttpServletResponse.SC_NOT_FOUND) which works perfectly fine, but it's not very Grails-like. I know Rails' render method take a status argu...

GORM Hibernate query

Hi, I have the following Grails domain objects class ProductType { String name static hasMany = [attributes: Attribute] } class Attribute { Boolean mandatory = false Integer seq static belongsTo = [productType: ProductType] } I would like to get all ProductTypes and their mandatory Attributes. Furthermore, I'd ...

How is the Eclipse JDK setting affecting the system's JDK setting

I was trying to compile a Grails application referencing third party JARs on Mac OSX. Although my system's JRE and JDK is set to Java 1.6 I always got a Compilation error: java.lang.UnsupportedClassVersionError: Bad version number in .class file when accessing classes in the JAR. Also when testing an existing Grails app the default stats...

Making Grails data-binding interpret empty String values ("") as zero (0)

This question is about altering how the Grails data-binding handles string-to-integer conversion. Consider the following domain object: class Foo { String name Integer price } Furthermore, assume that the domain object is populated from HTTP request parameters: def foo = new Foo(params).save() The save() method above will fail...

eager-loading queries with GORM/Hibernate

Hi, My Grails app has the following domain objects class ProductType { String name static hasMany = [attributes: Attribute] } class Attribute { String name static belongsTo = [productType: ProductType] } My DB has 7 ProductTypes and each of those has 3 Attributes. If I execute the query: def results = Product...

How do I set where my grails plugins should be installed?

Hi I saw the light and install the joda-time plugin for grails. However, when I tried to commit my changes to source control I realised that grails had located the files in: C:\Users\Steve\.grails\1.1.1\plugins instead of somewhere under the project directory of: f:\grails\projects\myproject Yeah I'm using windows :-\ So now whe...

Strings > 4000 to CLOB conversion using hibernate

Hi, i have a java class persisting a string (>4k) into a database table into a CLOB field. If the string is less than 4k then it works. I have the field annotated using @Lob and initially I was getting an exception due to batching not supported for streams so I made the batch size 0 in the Hibernate config which is giving the exception...

Finding the first match - alternative to DomainClass.findAll()[0]

Is there a shorter/cleaner way than DomainClass.findAll()[0] to retrieve the first domain object in the set of domain objects that would normally be retrieved by findAll()? Ideally, I'd like DomainClass.find() but such a finder does not exist. ...

Catch-all exception handler in Grails

How can I install an exception handler in Grails which catches all exceptions which propagate to the user? ...

Grails: Supplying Data to a Global UI Element

Please pardon this newbie question... In Grails, if I want a partial to be embedded in a layout so that it appears globally, which requires live data, let's say a list of categories, where is the best place to pull the category data to feed it into the view? I realize this is a very basic question, but I haven't seen this covered in a...

"Reverse Search" Search function for in Grails App

I searching for an useful Plugin or Idea for my app for reverse search. I am not sure if it is he right english Word for it...so let me explain: I got a list of ingredient in my cooking app. If i choose to create a new receipt i have to scroll through the whole list of ingredients. I want to be able to add an Letter to the ingredient...

How to redirect to the last visited page in Grails app?

Hi, I am a newbie in Grails and I am struggling with many simple issues. For instance, I don't manage to find a proper way to go back to the last visited page when I login/logout from a template view that is displayed on the top layout of the page. My last try for solving this problem was to save the ${params.controller} and ${params....

Do I have to know groovy before learning grails?

Do I have to know groovy before learning grails? Thank you! ...

Different object with the same Identifier

Any ideas as to why I'd be getting this error: nested exception is org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [Product#6] From this code: def save = { def productInstance = new Product(params) if(!productInstance.hasErrors() && produc...

Grails on-premises

We have developed an application using Grails, intended to be hosted on our public server and now we have some customers that would like to install it on their premises. What would be a good way to license our application and limit it in time and in number of users? Thanks, Guy ...

What modeling technique/tool/diagram would you recommend for a rails/grails application?

I am interesting in a diagramming methodology that can capture user-interaction in a way that will incorporate the "screens" along with the "actions", and how those are driven by controllers,views and services. ...