Questions tagged [grails-domain-class]

deals with issues related to the definitions of domain model

689 questions
6
votes
1 answer

Grails-ElasticSearch Plugin: Conditional Indexing of domain instances

I am using Grails-ElasticSearch Plugin(0.0.2.5). I want to add a constraint to my domain instances before it is indexed in ElasticSearch. Example:- I have a domain class A with a field 'status', i want to add an abstraction between Database and…
6
votes
3 answers

Grails Domain Class : hasOne, hasMany without belongsTo

I am new to Grails. Can I use "hasOne" or "hasMany" without using "belongsTo" to another domain-class? Thanks in advance.
6
votes
2 answers

Search records bases on latest record in a hasmany relationship

I have two domains class DomainA { String name Date dateCreated Date lastUpdated static transients = ['email'] static hasMany = [domainBs: DomainB] public String getEmail() { …
MKB
  • 7,587
  • 9
  • 45
  • 71
6
votes
1 answer

Mapping hasMany relation and saving the related data

I have two domain classes Question and Tag. Question has 'hasMany relation' with Tag. I am trying to save a question with some tags, but the error message is "Failed to convert property value of type java.lang.String to required type com.org.Tag…
6
votes
3 answers

Deserialize joda time from string in grails?

I had a LocalTime field (using Joda Time) in Grails domain class. Class WorkDone{ LocalTime duration } Now I have altered this field to String (with Text constraint) so that it can support duration larger than 24 hrs. String duration The…
6
votes
3 answers

How to set default value for Domain Class Values in Grails 2.2?

In my Grails domain class I want to set default values which do persist in the database. I use mysql as database. I tried to do this: class A { long someValue = 1 long someOtherValue boolean someBool = true boolean someOtherBool …
Michael
  • 32,527
  • 49
  • 210
  • 370
6
votes
2 answers

Grails Scaffolding - define possible values for this property of a domain class

I am new to Grails. I have a Person domain class as : class Person { String firstName String lastName String gender Date dateOfBirth } And wondering if I can define possible values for a property - say gender as {M, F, U} so that…
gtiwari333
  • 24,554
  • 15
  • 75
  • 102
6
votes
1 answer

Rename Displayed Field Name in Grails Domain Class

Given the following Grails Domain Classes, how do I go about renaming the displayed field name for isbn to be "ISBN" (as opposed to the default "Isbn") and authors to be "Author(s)" (as opposed to the default "Authors")? class Book { String…
starryknight64
  • 504
  • 7
  • 15
5
votes
2 answers

Accessing DB Without Domain Classes With Grails

I've ran into an issue while trying to put together a Grails app with an AS400/DB2 database. I cannot get most of the files mapped because they do not have a unique field to use as an id. And even if they do they are a text based field and not in a…
jonsinfinity
  • 187
  • 3
  • 16
5
votes
1 answer

GORM events not firing in integration tests

Trying to integration test Grails GORM delete on an object with beforeDelete event. Problem is that the beforeDelete event is not being fired in Integration Tests: class ChallengeMembershipTests extends GroovyTestCase { void…
Todd M
  • 1,012
  • 1
  • 15
  • 25
5
votes
1 answer

How do I fake a validation error?

I'm using the Grails Webflow plugin. Here are the domain objects I'm working with: class Foo implements Serializable { String fooProp1, fooProp2 static constraints = { fooProp2 nullable: false } } class Bar…
Pat
  • 2,228
  • 3
  • 24
  • 33
5
votes
2 answers

How can I change column name convention in Grails?

For now I have field "String firstName" it converted to "first_name" and i want "firstname" as default in Hibernate. Is it posible?
yura
  • 14,489
  • 21
  • 77
  • 126
5
votes
2 answers

How to adjust constraints / DB mapping for Map within grails domain class

Following grails domain class: class MyClass { Map myMap } Now for myMap, grails automatically creates a new table for the elements in the map. However if I add elements which are too long (e.g. 1024 characters), I get a DB error. Can I somehow…
5
votes
2 answers

When should hasMany be used for N:1 relationships in grails domain classes?

In grails, I can implement an N:1 relationship like this: class Parent { hasMany = [children:Child] } class Child { belongsTo = [parent:Parent] } Now (if addTo and removeFrom is always properly used) I can get a Parent's children via…
Jörg Brenninkmeyer
  • 3,304
  • 2
  • 35
  • 50
5
votes
3 answers

Referencing domain objects from external grails project - Method on class [] was used outside of a Grails applications

I have two Grails Projects in Eclipse. I am referencing one project inside the other with the Configure Build Path setup. Running tests however throws an error java.lang.IllegalStateException: Method on class [com.example.domain.Phone] was used…
bdparrish
  • 3,216
  • 3
  • 37
  • 58
1 2
3
45 46