deals with issues related to the definitions of domain model
Questions tagged [grails-domain-class]
689 questions
3
votes
1 answer
Dynamic scaffolding of multiple domain classes with single controller
For my web application in grails I have 3 admin controlling domain classes and no need of special UIs. For this I have decided to use dynamic scaffolding.
static scaffold = true; is scaffolding only one domain class.
Is there any way to scaffold all…

JiniKJohny
- 1,172
- 13
- 29
3
votes
2 answers
(unsaved) data in groovy in many-many relationship
My Data Domain:
class Course{
List teacherCourse
static hasMany = [courseByMultipleTeacher:TeacherCourse]
}
class Teacher{
String name
List teacherForCourses
static hasMany = [teacherForCourses:TeacherCourse]
}
class…

matuda
- 195
- 2
- 16
3
votes
1 answer
Sorting Parent and Child in Grails Controller
Hi I'm trying to perform a sort in a controller of parent and child before rendering a json file but I'm not sure how to go about doing it. Here's what I have (excerpt of original code):
class Parent{
static hasMany = [children:Child]
String…

codeBarer
- 2,238
- 7
- 44
- 75
3
votes
1 answer
Domain Class Functions vs. Service Functions [Grails]
I need to save and update properties of different domain classes in one transaction.
I know I can use the following:
def addToChildren(String name, int age) {
User.withTransaction {
def user = new User(name)
user.age = age
…

Michael
- 32,527
- 49
- 210
- 370
3
votes
2 answers
How do I change the name of a Grails domain class id field?
I have a Grails 2.2.3 domain class called FundType that I am trying to map to a legacy database table. It has two fields: code and description. I would like the id to be called code anytime I use the domain class and preferably on any of the…

grantmcconnaughey
- 10,130
- 10
- 37
- 66
3
votes
3 answers
Validate ip address in Grails
I am looking for a way to validate IP addresses in Grails via constraints.
Is something like this possible?
package example
class Ip {
String ip
static constraints = {
ip(unique: true, inetAddress: true)
}
}
I have found this…

mbs
- 421
- 2
- 8
- 28
3
votes
2 answers
Grails integration test for domain class: No signature of method exception
I try to write integration test for domain classes in my project. However each time I run the test I got some errors.
My code is below:
class ProductIntegrationTest extends GroovyTestCase {
void testSave() {
def product = new…

ttt
- 3,934
- 8
- 46
- 85
3
votes
2 answers
Grails: Understanding groovy DomainClass.properties
I'm having a hard time finding information about grails functionality:
DomainClass.properties = params
In my particular case, I have these classes:
class parameterType = {
String name
String desc
static hasMany = [codes :…

Johnny C.
- 368
- 1
- 5
- 20
3
votes
3 answers
Grails - Initiating domain class using JSON
I have this simple domain class:
class Settings {
static constraints = {
uid(nullable: false, unique: true)
person()
}
String uid
Map person
}
and a web UI that update the data using a json request:
{"uid":1234 , person:{"first_name" :…

Shlomi Schwartz
- 8,693
- 29
- 109
- 186
3
votes
1 answer
Neo4j: spring-data-neo4j,how to cast result to my type class?
I have insert some node into Neo4j DB.And I want to select some node from database and cast it to specific class.
Here are some code about the problem:
class Service {
Neo4jTemplate neo4jTemplate
@Transactional
def find() {
def…

kelvin7.feng
- 43
- 6
3
votes
1 answer
Mapping Grails Domain object to JDBC table/sequence
I am trying to map an existing oracle table to a new Grails Domain Object. I also have an existing sequence. When calling "run-app", I get an error:
Unsuccessful: create sequence hibernate_sequence
ORA-01031: insufficient privileges
My goal is to…

Noa
- 33
- 1
- 3
3
votes
1 answer
Is there a belongsTo mixed syntax for GORM many-to-many and back-reference
I've come across a peculiarity in GORM mapping.
What I expect table-wise is
models
designs (model_id -> models.id)
categories
categories_design (category_id, design_id)
To get a model_id in designs, I would use map syntax
static belongsTo =…

PorridgeBear
- 1,183
- 1
- 12
- 19
3
votes
2 answers
How to dynamically add a property / field to a domain class in Grails?
For a project I'm currently working on I need to dynamically add properties to a domain class and persist them later in the database. In general, I need a key/value store attached to a "normal" domain class. Sadly I cannot use a NoSQL database (e.g.…

Jörg Rech
- 1,339
- 2
- 13
- 25
3
votes
1 answer
How to avoid loss of DB when changing Grails domain class in development
One of the advantages of Grails 2.0 is that you can change domain classes in development without needing to restart the application server. This works, however when I change domain classes I lose all my bootstrap data, which basically defeats the…

Fletch
- 4,829
- 2
- 41
- 55
3
votes
0 answers
How to intercept dynamic methods of domain objects with AOP or some other way?
I would like to wrap Domain class's dynamic methods like save() get*() with an Around advice (possibly using Spring AOP). The idea is to intercept these methods and take the decision to apply them or not. As part of it I would also like to save the…

ShriKant Vashishtha
- 321
- 3
- 5