GrailsBrains

GrailsBrains We started off in 2011 as a small team to build amazing products and solutions for companies spread across the globe.

Over time we have built hundreds of web, mobile and enterprise applications in various verticals including but not limited to supply chain, e-commerce, order management, analytics and digital marketing. We use Grails, Java and Android technologies. We are among the first in the industry to adopt Grails as primary development technology- started with Grails 1.x and now on Grails 3.x.

http://www.grailsbrains.com/using-spring-security-rest-api-grails-3-x/
07/10/2017

http://www.grailsbrains.com/using-spring-security-rest-api-grails-3-x/

Add “compile “org.grails.plugins:spring-security-rest:2.0.0.M2″” in your build.gradle file in dependencies. Then add these properties in your application.groovy file. grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.user.User' //spring security for domain class for user grails.plug...

23/08/2017

Search parent through child in aggregation(hasMany but not belongsTo) relationship

Lets for example take these two domain objects

class Corporation {

String name

static hasMany = [locations:Location]

}

class Location {

String description

String address

}

As you can see Corporation has many locations but Location does not belong to Corporation. How would you quickly get to Corporation when you have handle to Location? Named query comes to rescue- see the changed Corporation code – “findByLocation” is the named query which acts like a dynamic property of the domain object; dynamic in the sense that it would not be persisted.

class Corporation {

String name

static hasMany = [locations:Location]

static namedQueries = {

findByLocation { locationId ->

locations { eq 'id', locationId }

}

}

}

With this changed corporation code, one can easily find the Corporation which contains the given Location. See the below code illustration-

def location = Location.findByAddress("some-location")

//use of named query findByLocation

def corporation = Corporation.findByLocation(location.id).get()

For more grails related queries please visit our blog http://www.grailsbrains.com/blog/

Address

C-004, Renaissance Jagriti
Bangalore
560066

Opening Hours

Monday 9am - 6pm
Tuesday 9am - 6pm
Wednesday 9am - 6pm
Thursday 9am - 6pm
Friday 9am - 6pm

Alerts

Be the first to know and let us send you an email when GrailsBrains posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share