Home » Tag Archives: Grails

Tag Archives: Grails

Groovy for Java Developers?! Meet Gradle, Grails and Spock

gradle-logo

What are some of the most interesting Groovy use cases for Java developers? Although it’s been around for a while, it seems that only lately Groovy has been getting its Groove on. It is mostly just another esoteric JVM language for some, but it’s more popular than you think thanks to some popular tools that use it to help you ...

Read More »

Building GORM Criteria Queries Dynamically

grails-logo

I originally wrote most of the queries in the spring-security-ui plugin using HQL because I find it more intuitive than criteria queries, but HQL only works with Hibernate and relational databases. A pull request updated the queries to use criteria queries to allow the plugin to be used with NoSQL datastores, but one query didn’t fit the programming style that ...

Read More »

Grails 3 DataSource Configuration

grails-logo

Grails 3 has new configuration files and format.  The new format is based on YAML and the file name to use for database configuration is grails-app/conf/application.yml.   I’m just getting started with Grails 3 after developing applications on Grails pre-1, 1 and 2.  I was looking forward to building a new Grails 3 application. Before I began, I read the ...

Read More »

Custom User types in GORM

grails-logo

Recently, I wanted to model a Merchant which like many things in a domain model had an Address. I thought it made sense that the Address was embedded inside the Merchant. Reasons: It had no lifecycle outside the Merchant. Merchant dies so should the address. It only ever belonged to one and only one Merchant So pretty obvious this was ...

Read More »

Using separate Postgres Schemas for the same database in a Grails App

grails-logo

Recently, I wanted to use the same Postgres Database but split my persistence layer into separate components which used separate schemas. The motivation was to promote modular design, separate concerns and stop developers tripping up over each other. Vertical domain models can be difficult to achieve but not impossible. In my shopping application, I had a user component, a shopping ...

Read More »

Grails’ JSONObject.NULL More or Less Equal To Null

grails-logo

Since Groovy 1.8 we can check if a Map is equal to another Map if the keys and values are the same. Very convenient in tests for example. def someMap = [age: 34, name: "Ted"] assert someMap == [name: "Ted", age: 34] Today I kept staring at a failure, while testing some x and y graph data points returned by ...

Read More »

Grails Goodness: Custom Data Binding with @DataBinding Annotation

grails-logo

Grails has a data binding mechanism that will convert request parameters to properties of an object of different types. We can customize the default data binding in different ways. One of them is using the @DataBinding annotation. We use a closure as argument for the annotation in which we must return the converted value. We get two arguments, the first ...

Read More »

Grails Goodness: Adding Health Check Indicators

grails-logo

With Grails 3 we also get Spring Boot Actuator. We can use Spring Boot Actuator to add some production-ready features for monitoring and managing our Grails application. One of the features is the addition of some endpoints with information about our application. By default we already have a /health endpoint when we start a Grails (3+) application. It gives back ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials