Hi,
My Grails app has the following Spring bean defined in spring/resources.groovy
calendarService(CalendarService) { bean ->
bean.initMethod = "init"
}
This method looks something like:
class CalendarService {
void init() {
User.findByEmail("[email protected]")
}
}
When I call the dynamic finder findByEmail ...
I have a property that can be nullable or required depending on the status of another variable.
class Person{
name()
civilStatus(inList:['Single','Married','Divorced','Widowed'])
partnerOrSpouse()
}
the partnerOrSpouse property is nullable or not depending on the value of the civilStatus property.
...
I'm just wondering if it's possible for 'createCriteria' to specify the paginateParams (i.e. offset) similar to dynamic finder (findAll, etc.)
Note that this code is not working since 'offset' is not documented in http://www.grails.org/doc/1.2.1/ref/Domain%20Classes/createCriteria.html
def c = SnbrItemActDistance.createCriteria()
def r...
I have two domains :
class CodeSet {
String id
String owner
String comments
String geneRLF
String systemAPF
static hasMany = [cartridges:Cartridge]
static constraints = {
id(unique:true,blank:false)
}
static mapping = {
table 'code_set'
version false
columns {
id column:'code...
It seems that there are two different ways of declaring sorted associations in Grails :
Method 1 (see here) using default sort order
class Book {
String title
}
class Author {
static hasMany = [books : Book]
static mapping = { books sort: "title"}
}
Method 2 (see here) using SortedSet
class Book implements Comparable {
Stri...
Suppose I have the following Domain class mapping to a legacy table, utilizing read-only second-level cache, and having a transient field:
class DomainObject {
static def transients = ['userId']
Long id
Long userId
static mapping = {
cache usage: 'read-only'
table 'SOME_TABLE'
}
}
I have a problem, references to DomainObjec...
I have two domains :
class CodeSetDetail {
String id
String codeSummaryId
static hasMany = [codes:CodeSummary]
static constraints = {
id(unique:true,blank:false)
}
static mapping = {
version false
id column:'code_set_detail_id', generator: 'assigned'
}
}
and :
class CodeSummary {
String i...
OK here is stripped down version of what I have in my app
Artist domain:
class Artist {
String name
Date lastMined
def artistService
static transients = ['artistService']
static hasMany = [events: Event]
static constraints = {
name(unique: true)
lastMined(nullable: true)
}
def mine() ...
Let's say I have a UserAccount domain class that has a UserPreferences domain class. I do this to separate the fields for organization purposes. Is there a way to tell grails/gorm that I really want it to map these domain classes to just the user_account table under the covers?
Thanks!
...
Hello
I am new to grails and trying to create a form which allows a user to change the email address associated with his/her account for a site I am creating.
It asks for the user for their current password and also for the new email address they want to use.
If the user enters the wrong password or an invalid email address then it sho...
I have to calculate a "total" for each user based on individual actions -- that is, a User hasMany Actions and each Action has a point. So I need to basically get a sum of all the points on all the actions.
Actions are added and subtracted regularly. Since this can be a rather heavy operation, it's not feasible that I execute the "tota...
Does grails have an automatic constraint update. If we change the field in domain class to be nullable by adding constraint, it is not getting reflected in database without schema export. Is it possible to do get grails do this update automatically.
...
Hi, I have the following Domain Class:
class Metric {
String name
float value
static belongsTo = [Person,Corporation]
static indexes = {
name()
}
}
How can I add a constraint so Person,Corporation and name are unique ?
Thanks.
...
For a grails application, I need to find a list of objects whose "attr" is one in a dynamic list of strings. The actual HQL query is more complex, but the bit I need help with is this:
def result = MyObject.executeQuery("select o from MyObject as o where o.attr in :list",
[list: aListOfStrings])
This is obviously not the right syn...
I'm trying to create a very simple relationship between two objects. Can anybody explain me why I can't find the Company object via findBy method?
class Company {
String name
String desc
City city
static constraints = {
city(unique: true)
}
}
class City {
String name
static constraints = {
}
}
cla...
I have a CSV file with a list of "banned usernames" --it's about 10,000 names. Basically I want to check against this list upon user registration. I'd like to load this list in my database but I'd rather not create a domain object for each name and BootStrap them. However, I'd also like to stay within the Grails framework as far as manag...
Hi
I'm fighting to get the following mapping working in Grails 1.3.1 and MySQL:
class Login {
int id
String email
static mappings = {
table 'my_table'
id column: "Mgr_id"
version: false
}
}
No matter what I do the queries that are being issued refer to "schema.login" table instead of "schema....
I'm just wondering if it's possible for 'createCriteria' to specify the contains group similar to CharIndex('P', Channel) <> 0
I am using eq and get exact match but what should i use in i need to get all the records which contains channel similar to IN("channel",('a','b','c','d'))
def c = Load.createCriteria()
def results = c {
...
I'm blocked on this GORM inheritance problem I have and id appreciate some fresh eyes to have a look over this problem. (Im using Grails 1.3.2)
I have a base abstract class...
abstract class MaintenanceSchedule {
static belongsTo = [ maintenanceTask:MaintenanceTask ]
}
and I want to extend it like so...
class OneOffSchedule exte...
I want any field to be nullable in default.
...