Grails domain class: unique constraint for multiple columns

userName(unique: [‘countryId’]) You can include as many other properties in the array that make up the other properties that must be considered in the “unique” constraint on the username. So, for example if you wanted to make userName unique within a countryId and provinceId it would look like this: userName(unique: [‘countryId’, ‘provinceId’]

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

Setting the response status with its own statement is good enough. It doesn’t look too ugly and is pretty straightforward: response.status = 404; I’ve used this successfully myself and have seen others do it this way too. Since it’s just a setter, you can also do other stuff after setting the status. Whichever status you … Read more

how to parse json using groovy

Have you tried using JsonSlurper? Example usage: def slurper = new JsonSlurper() def result = slurper.parseText(‘{“person”:{“name”:”Guillaume”,”age”:33,”pets”:[“dog”,”cat”]}}’) assert result.person.name == “Guillaume” assert result.person.age == 33 assert result.person.pets.size() == 2 assert result.person.pets[0] == “dog” assert result.person.pets[1] == “cat”

Best practices for deploying Java webapps with minimal downtime?

Update: Since this answer was first written, a better way to deploy war files to tomcat with zero downtime has emerged. In recent versions of tomcat you can include version numbers in your war filenames. So for example, you can deploy the files ROOT##001.war and ROOT##002.war to the same context simultaneously. Everything after the ## … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)