Questions tagged [grails-domain-class]

deals with issues related to the definitions of domain model

689 questions
3
votes
2 answers

Grails hasMany: find all master records with a child that matches a criteria

I have this Grails 2.0.3 project wherein there are two models DomainA and DomainB and both are related to each other by a many-to-many relationship in which DomainB is a child of DomainA. class DomainA { // properties static hasMany = [domains:…
David B
  • 3,269
  • 12
  • 48
  • 80
3
votes
2 answers

Child class object can not delete

I have some domain class Incident,Problem, Category, Impact, Urgency etc. Class Incident { Category category String subject Impact impact } Class Problem { Urgency urgency Category category String title } Class Category { …
sanghavi7
  • 758
  • 1
  • 15
  • 38
3
votes
3 answers

Grails "One to Many" relationship without a table join

I'm new to Grails and GORM and I try to implement a "One to Many" relationship. I tried the example in the doc : class Book { String title } class Author { static hasMany = [books: Book] String name } Here are the tables that are…
Yann
  • 303
  • 1
  • 5
  • 11
2
votes
2 answers

custom validation messages in grails

I have a domain constraint which I am validating like userName(blank:false, nullable:false, Size: 5..50,matches:'^[A-Za-z\\d]*$',validator:{chkUser,user->if(user.loginService.getUser(user.organizationId,user.userName)!=null){ …
2
votes
4 answers

Grails: sort order on one-to-many relationship not working

I've got a simple bi-directional one-to-many mapping, as follows, with a default sort order specified on the owning side. However, the sort order doesn't seem to be getting applied? I'm using Grails v2.0.1 (I've now replicated this example with…
owenrh
  • 71
  • 1
  • 6
2
votes
1 answer

Grails db-migration table already exists

I'm using Grails 1.3.7 and the db-migration plug-in. I have generated a chagelog.groovy-file containing my delta, I set theese properties: grails.plugin.databasemigration.updateOnStart = true grails.plugin.databasemigration.updateOnStartFileNames =…
marko
  • 3,736
  • 6
  • 29
  • 46
2
votes
2 answers

Tips for saving a large domain object tree

I'm trying to save a large grails domain object structure, where the number of domain classes is a handful, but the number of objects around a hundred. The objects are linked using classic grails hasMany. The basic idea is to wipe the database…
2
votes
2 answers

How To Put A Constraint On Relationships In A Domain Class, In Grails?

I have a domain three domain class like this : Tasks.groovy class Tasks { static belongsTo = [ user : User ] //other fields Date startDate Date endDate } User.groovy class User { //relationships. . . . static belongsTo =…
Ant's
  • 13,545
  • 27
  • 98
  • 148
2
votes
2 answers

Grails domain beforeInsert / beforeUpdate

I want to save my domain class to the database without specifying the createdUser or createdDate. I’ve created an object called AuditingInfo and embedded it in the main Person domain class like this: AuditingInfo.groovy: class AuditingInfo { …
Đinh Hồng Châu
  • 5,300
  • 15
  • 53
  • 90
2
votes
1 answer

grails4 migration Traits lazy load issue - HHH000142: Bytecode enhancement failed

I have migrated my application from Grails-3.x to Grails-4.1.1 Most of my Domain classes implemented the following Traits class (DynamicProperties), which has an implementation of GormEntity for some reason - to override the propertyMissing…
Abdul
  • 81
  • 8
2
votes
0 answers

java.lang.AbstractMethodError in org.grails.testing.gorm.spock.DataTestSetupSpecInterceptor on Grails 4.0.11

I am facing an issue in the Spock framework. I have upgraded my application from Grails 3 to Grails 4. I have used Mixin in Grails 3 but since Grails 3.3, mixin is removed. Now I am using the Spock framework. I have created a sample Domain class and…
2
votes
3 answers

Inherit Grails Domain Class properties from a base Class

Im trying to create a Domain Class Constructor that inherits another class properties dynamically. But I cannot get it to work properly. Heres an example: class Example1 { String name; String location; } class Example2 extends Example1 { …
Gregor
  • 133
  • 1
  • 7
2
votes
1 answer

Grails Gorm Partial Save

I have a very basic question in saving objects which I get from a client sent via JSON. I have a customer object which is transfered to the client, after editing the customer its send back to Grails and needs to be saved in the database. For…
Gambo
  • 1,572
  • 3
  • 26
  • 52
2
votes
1 answer

grails 1.3.7 + 2.0, section 5.2.1.1, Many-to-one and one-to-one

Section 5.2.1.1 has examples A - C, which seem a bit confusing: Example B: Is this still a many-to-1 relationship, like Example A (i.e. same table setup)? At the end it says, "to make a true one-to-one, use the hasOne property ...". Example C: …
Ray
  • 5,885
  • 16
  • 61
  • 97
2
votes
3 answers

Grails - adding custom fields (columns) to all domain objects - automatically

By default when you create a domain class, it will automatically add "id" and "version" column for all the domain classes (tables). What if I want to add a column say for e.g. "isChecked" and this should be added automatically to all the domain…
Jay Chandran
  • 382
  • 1
  • 8
  • 20