grails

What is the tradeoff in replacing Java with Grails?

Having used Java for some years already, we know what we are gaining by moving to Grails. The question is, what are we losing? Performance? Appreciate your input / ideas. Thanks. ...

Issue with multiple hasMany relationships to the same domain class when using composite id

I am getting this exception: org.hibernate.MappingException: collection foreign key mapping has wrong number of columns: Room.cellsOrig type: component[locationX,locationY] class Room implements Serializable { Integer locationX; Integer locationY; List cellsOrig = [] List cells = [] static hasMany = [cellsOrig: Cell...

What's the best way to build a queue for long-running jobs in a Grails app?

I have a Grails app that has some computationally intensive optimizations with a running time of ~5 minutes (perhaps more). Currently, I'm doing these in the main request thread, i.e. it takes 5 minutes for the request to return. It works, but is of course horrible from a usability perspective. So what's the best way to implement this i...

Spring MVC or Grails?

I'm new to the web programming world, and I'm trying to learn about various Java MVC frameworks available. Through my research, I came across Spring MVC and Grails. My question is: which one is better for developing enterprise web applications, or is there another option I haven't run across yet? Important considerations: Must be su...

grails xfire can't seem to send large blobs

I am running a groovy program that zips up some files and then I need to send that file to an XFIRE web service - what is the best way to get this done? the file(s) could be 1-5 Megs at most Thanks! The following code code byte[] data = new File(file).readBytes() def getProxy(wsdl, classLoader) { new WSClient(wsdl, classLoader) }...

Can I use grails tag outside of GSP

For example, i can put <g:createLink controller="user" action="show" /> inside a .gsp file and it will work nicely. But also I'd like to use the same closure createLink inside a .groovy file which is not part of the grails views ...

Grails + sqlite

Is there any way to use SQLite as a database storage for my Grails app? If I use a SQLite JDBC driver (http://www.zentus.com/sqlitejdbc/), my app fails to start with "Could not determine Hibernate dialect for database name [SQLite]" The only workaround I found was http://d.hatena.ne.jp/torutk/20090711/p3 (it's in Japanese, have it goog...

Does Grails have anything like acts_as_tree in Rails?

I am just getting into Grails having had some experience with Rails, and I am looking at creating an app where I have to primarily persist tree structures (and query them as well). Rails has several very useful acts_as helpers for representing domain objects as different data structures, such as acts_as_tree. From my initial reading it ...

Using Java Domain Objects With Spring Security Plugin

I'm working with a legacy database and corresponding Java Domain Classes. I'm trying to add Spring Security to the app and I'd like to use Java Domain Classes for that too, just to be consistent and keep everything together. Grails has no problem using both POGOs and POJOs, btw. So, starting with a new, empty database and a new empty gr...

Grails domain unit testing - mockFor()

Hi, This is the domain class: class Registration { String email String generatedKey def beforeInsert = { String newToken = GlobalHelper.getRandomString() generatedKey = newToken } } and this is the relevant part of the unit test: def c = mockFor(GlobalHelper) c.demand.static.getRandomString {-> return "...

alternated default sort in GRAILS

Hi, why the following Groovy snippet returns alternating [Account: 2222 and 2222, Account: 1111 and 1111] or [Account: 1111 and 1111, Account: 2222 and 2222] if you run it multiple times within the Groovy Console ? I thought the sort statement leads to an ALWAYS descending sort order of the list ??? class Account { long number ...

Bundling images with Grails plugins, refering those images from an application using the plugin does not work

I've created a plugin doing some crud operations. In the web-app/images/icons folder I've got some icons representing various operations. The following works great when running the plugin, but as soon as the plugin is installed in an application it stops working. It does not look like images from plugins are made available in the appli...

Grails: Adding sorting and paging to a custom HQL query

I have a list method that uses HQL. how do I add the paging and sorting parameters to this query? def list = { def termList log.info "Getting terms for product: $params.productId" params.max = 10 def p = Product.get(params.productId) if (p) { log.info "Product found: $p.name" ...

Is there a good reference for how Grails was architected with Spring?

I have come to Grails without first being a Spring developer. This is great when things work but leaves me lost when things don't work as I expect, or I wish to extend things in ways unanticipated by the existing Grails documentation and reference books. I would also like to learn more about Spring best practices and with a reference I ...

Mocking out constructors in Grails

I'm new to testing in Grails, so I'm not sure if I'm taking the correct approach. I am trying to unit test a service (call it FooService) that has an instance of another class (call it Bar) as a property. Basically something like: class FooService { Bar bar void afterPropertiesSet() { bar = new Bar() } } So, I'm trying to test...

What are the Grails bugs that developers have to work around?

In some of the articles I've read, and some of the podcasts I've heard, people have been saying they need to work around a number of bugs existing in Grails. As a beginner Grails developer, how will I know what those bugs are ( so that I wouldn't have to waste time researching them )? Are they listed somewhere? ...

GRAILS: Find all children in a self-referenced one-to-many relationship

In grails, How would one find all the children in a one-to-many relationship e.g., class Employee { static hasMany = [ subordinates: Employee ] static belongsTo = [ manager: Employee ] } Using a single manager, how would one get the subordinates of all subordinates (like traversing a object graph)? ...

How do you modify a Domain Class in Grails?

I can't figure how what the "standard practice" is for modifying a Domain Class after it has automatically created the corresponding database table. There's no "migration" in Grails, and there's no way that I can find to tell it to output the new SQL it would generate so you can compare it to the previous table definition and manually i...

I can't get the grails controller "render" method to work with an explicit template

I'm just getting started with grails, and I'm having an issue. I have a "controller" and "view" for the projects home page (there's no model for the home page) I called the view "index.gsp", and put it in a directory views/home However, no matter what I do, grails is trying to read the page "home.gsp" (and then home.jsp), despite me h...

I cant get Domain.count() static method to work

The Grails documentation defines a "count" static method, defined in the documentation like this: Description Counts the number of instances in the database and returns the result Parameters None Example def noOfBooks = Book.count() However, whenever I call it, I get this error! I simple added a call to the name of m...