Questions tagged [grails-domain-class]

deals with issues related to the definitions of domain model

689 questions
4
votes
5 answers

Grails Missing type or column for column[order_items_order_item] on domain[rewards.OnlineOrder] referencing[rewards.OrderItem]

So I keep getting the subject line error when trying to run my grails app. Here are my two domain classes that appear to be the cause of the error. OnlineOrder: package rewards class OnlineOrder { Date orderDate Integer orderNumber …
Andrew Hummel
  • 400
  • 2
  • 5
  • 22
4
votes
1 answer

Grails Domain: allow null but no blank for a string

Environment: Grails 2.3.8 I have a requirement that the user's password could null but can't be blank. So I define the domain like this: class User{ ... String password static constraints = { ... password nullable:true,…
Aiden Zhao
  • 564
  • 5
  • 24
4
votes
0 answers

How to update an instance with field unique that has not changed in Grails?

I have a problem when trying to update an instance that has a field with constraint: unique, but has not been modified. https://grails.github.io/grails-doc/latest/ref/Constraints/unique.html class SectorEmpresarial{ Long codigo String…
4
votes
2 answers

GORM: What is reference:true in Grails domain class mapping block?

public class Address { static mapWith = "mongo" Region region; Zone zone; static mapping = { id generator: 'identity' region reference:true zone reference:true } } I'm interested in knowing what…
Alexander Suraphel
  • 10,103
  • 10
  • 55
  • 90
4
votes
1 answer

Grails 2.4.2 - Dynamically referencing default datasource

This question has been partly answered here but there is still an issue with referencing the default datasource dynamically. I'm working on an internal application that allows developers to modify configuration settings for one of our multi-tenant…
4
votes
2 answers

GORM Relations without dependent delete

I have two domain classes User and Node. The following conditions should hold. a User can have zero or one node a Node can have one to n User (it is always initialized with a User instance) if you delete a Node the User will not be deleted if you…
Michael
  • 32,527
  • 49
  • 210
  • 370
4
votes
1 answer

Issue Updating Grails Domain Class

I am having an issue with a simple update of a Grails Domain class and I really need a sanity check. My domain class is class Container implements Serializable{ String barcode Float tare static hasOne = [containerContent:ContainerContent,…
Dennis
  • 401
  • 5
  • 17
4
votes
2 answers

How to implement Self-Referencing Relationships in Grails?

Given the following User class: class User { String name static hasMany = [friends: User] } I want that a User can have many friends which are instances of the user domain class. How do I have to implement the friend relationship of a user?
Michael
  • 32,527
  • 49
  • 210
  • 370
4
votes
2 answers

Working with time as a Grails domain class field

I have a Grails domain class called Event. It has a startTime and an endTime. What object would these two fields be represented as? I need them to persist to the database, so keep that in mind. I don't need to do anything with a particular date,…
grantmcconnaughey
  • 10,130
  • 10
  • 37
  • 66
4
votes
2 answers

How can I use embedded GORM classes in Grails?

Following the GORM docs I tried to use the following domain class with Grails 2.2.1: package grailscompositiontest class ScafPerson { String name ScafAddress homeAddress ScafAddress workAddress static constraints = { …
blerontin
  • 2,892
  • 5
  • 34
  • 60
4
votes
2 answers

Grails: How can I create named unique constraint for multiple columns?

How can I create named unique constraint for multiple columns? I've three classes: class Descriptor { // some columns } class Protein { // some columns } class DescriptorValue { // some columns static belongsTo = [protein: Protein,…
4
votes
1 answer

grails: Passing a grails domain class as a function argument

I have two (5 in fact) domain classes, ClassA and ClassB and have to execute the same query on both ClassA.where { a == b }.list() and ClassB.where { a == b }.list() I want to write a service class to execute these queries passing the Class…
Alejandro Vera
  • 377
  • 2
  • 12
4
votes
4 answers

Grails - MongoDB and custom dirty checking

I am using MongoDB and Spring Security Core and UI on my application. Nearly everything works perfectly, except this bit: def beforeUpdate() { if (isDirty('password')) { encodePassword() } } which is part of…
Alexandre Bourlier
  • 3,972
  • 4
  • 44
  • 76
4
votes
1 answer

Grails: map mysql field of type enum to domain class

How can I map a mysql field of type enum to a grails domain class? I'm using an existing (legacy) mySQL database with grails v.2.0.3. I'm getting an error for Wrong column type: failed; nested exception is org.hibernate.HibernateException: Wrong…
ibaralf
  • 12,218
  • 5
  • 47
  • 69
4
votes
2 answers

Converting xml to domain object in Grails

I'm a grails newbie working on a project for fun. I'm serializing a class like this: def msg = (listing as XML).toString() the trying to deserialize a class using the XMLSlurper like this: def root = new XmlSlurper().parseText(listingString) def…
dalcantara
  • 1,613
  • 2
  • 21
  • 35