Questions tagged [grails-domain-class]

deals with issues related to the definitions of domain model

689 questions
3
votes
2 answers

add user define properties to a domain class

i have a requirement to allow the user to define some custom field in one of the system entities. do you have any suggestion/pattern/plugin that will help me add this feature to my application. thanks, Meni
3
votes
1 answer

How to run Grails script and get domain class instance

How to get current application environment in Grails scripts to be able to work with classes and objects like grails console does. My script: import security.User List users = User.list() users.each { User user -> print(user.name) } And I get…
Alex Shwarc
  • 822
  • 10
  • 20
3
votes
1 answer

Cannot redirect for object [ManageVehicle : (unsaved)] it is not a domain or has no identifier. Use an explicit redirect instead

This is my domain. import org.apache.commons.lang.builder.EqualsBuilder import org.apache.commons.lang.builder.HashCodeBuilder class ManageVehicle implements Serializable { String vehicle Short truckKey=0 Short siteID Integer…
3
votes
0 answers

How to handle errors that occur in @BindUsing annotation closure

I have a property with custom data binding like this: class User { // Custom data binding for the image @BindUsing({ obj, source -> def imageFile = source['image'] if (imageFile && imageFile.size > 0) { Document…
deflomu
  • 596
  • 1
  • 4
  • 16
3
votes
1 answer

BeforeInsert and BeforeUpdate are fired twice in grails domain class

I am using grails version 2.1.0 in my application and i have a before insert in my domain class which encodes the password as below. package com.valuelabs.bets.security class SecUser { transient springSecurityService String username String…
Srinivas21
  • 63
  • 4
3
votes
1 answer

Pull domain mapping in bootstrap and modify it Grails

I am currently using Grails-2.2.4, I would like to modify the behaviour of my domain mapping from bootstrap to alter the dateCreated Field to custom date. While trying to pull the mapping of domain to modify the autotimestamp behaviour, the…
3
votes
1 answer

Grails + GORM: What is the default equals() implementation in GORM?

When I do domainObj1 == domainObj2 in Grails are the objects compared by ID? If not, how are they compared?
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90
3
votes
2 answers

Grails: Unit testing controller method with domain class

I have a simple grails controller: class AuthorController { def index(){ def authors = Author.findByFirstName("Albert") render (view: "author-page", model: ["authors":authors]) } } Here, Author is a domain class that maps to…
Stealth
  • 1,559
  • 4
  • 16
  • 34
3
votes
1 answer

Why don't unflushed domain objects revert to their "saved" state after discard? Can I get the "clean" version?

Confused here about domain objects in intermediate states. So here's a class: class Foo { Double price String name Date creationDate = new Date() static constraints = { price min: 50D creationDate nullable: false …
GGizmos
  • 3,443
  • 4
  • 27
  • 72
3
votes
0 answers

Preserving an ordered index during dbm-gorm-diff

I have a Domain class mapped to a MySQL table via the database-migration plugin. For performance reasons, I needed an index created with attributes in a specific order. Every time I do a dbm-gorm-diff, however, the generated code wants to drop my…
rongenre
  • 1,334
  • 11
  • 21
3
votes
0 answers

Grails: Defining a JSON custom marshaller as static method in domain

I'm using Grails 2.4.2. As can be seen here: https://grails.org/Converters+Reference You can create a static method in your domain with your custom marshaller to render the JSON in the controller. Like that: Domain: // a class to output in JSON …
jBilbo
  • 1,683
  • 13
  • 24
3
votes
2 answers

Grails: Transients property in Constraints.groovy

I want to replace domain class in grails with a hibernate class(Rate). So constrains to hibernate class can be added by creating a file RateConstraints.groovy in src/java, and it works fine for validations of hibernate class. now i need to add…
Antony Prince
  • 319
  • 4
  • 17
3
votes
2 answers

how can i add a integer list in grails domain class

I have created a domain class as given below, which contains an int and list of Integer properties. class User { int UserId List UserFriendsId static constraints = { } User() { this.UserId = 21 …
An Ish A
  • 711
  • 5
  • 18
3
votes
1 answer

How to set formula in grails domain class?

I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', …
3
votes
1 answer

grails JdbcSQLException in saving one-one mapping domain class

I am new to grails , i have created a user domain class and userprofile domain class. and these class are hasone realtionship. the domain class is given below class User { transient springSecurityService String username String…
An Ish A
  • 711
  • 5
  • 18