Questions tagged [grails-domain-class]

deals with issues related to the definitions of domain model

689 questions
0
votes
2 answers

Grails strange removeFrom* behavior

I just encountered a strange behaviour when deleting a object from a hasManyRelation in grails 2.2.1. Deleting is not working with: def lessonInstance = Lesson.get(lessonId) long id = Long.valueOf(taskId) def task = Task.get(id) …
lwi
  • 1,682
  • 12
  • 21
0
votes
1 answer

grails 2.1.0 Chained select relation

I want to make chain select box in my view page. I have country select box, and city select box. And in city domain I have country id. Now I want to show cities of a specific country when I select a country. But I have no idea. I am using grails…
Sumon Bappi
  • 1,937
  • 8
  • 38
  • 82
0
votes
2 answers

How to set fields are not required in mongoDb using Grails 2.2.2

I create my first app in Grails 2.2.2 .. For database i am using MongoDb .. but it gives me an error if all fields are not filled..How to set mongoDb fields allows null
sagar mane
  • 123
  • 2
  • 13
0
votes
2 answers

How to iterate over object list in reverse order in Grails?

From a list of GORM database objects that are ordered desc in my user domain model I want to order them asc (i.e., in reverse order in the view). For example to get the latest books of a user from the database, but insert them in the Dom in reverse…
Michael
  • 32,527
  • 49
  • 210
  • 370
0
votes
4 answers

What is the best way to make Grails domain classes commentable?

I have different classes in my Grails application that a user should create comments for. E.g., Post, Book, Article Setting static hasMany = [comments: Comment] to each class seems to be a bad solution. What is the best way to make them…
Michael
  • 32,527
  • 49
  • 210
  • 370
0
votes
1 answer

How to set unique hasMany relations based class properties?

I have two domain classes: class Book { String name static hasMany = [articles: Article] } class Article { String name static belongsTo = [book: Book] } I want to validate that a book does have only unique articals in terms of…
Michael
  • 32,527
  • 49
  • 210
  • 370
0
votes
1 answer

GORM get method based on dependent criteria

I'm new to Groovy/Grails so this could be an easy question. I have the feeling this is common code but I've spent a while and I can't find the right thing to Google. I have a domain structure with several many to many relationships ( indicated by…
Bob McNees
  • 371
  • 5
  • 11
0
votes
2 answers

Retrieve domain instance by generated id

I am using a Domain class with a generated identity: class User { ... static mapping = { id generator: 'assigned', name: 'uid' } Long uid ... } but when I try to retrieve an instance using User.get(1) it returns null. It does…
chozero
  • 411
  • 6
  • 12
0
votes
1 answer

domain class in grails

please help me I have this class Class Person { String name String id Date date } This class is connected with mysql my question is where put this: Person.count() or Person.findByAllName("Carlos") Class Person { String name String id Date…
0
votes
2 answers

Grails Bypass beforeUpdate Method of a Domain class

I'm just curious if there is a way to bypass the beforeUpdate() and similar methods of a certain domain class. I need it for restoring the original password of a user. The beforeUpdate proceeds the password hashing algorithm which I wouldn't like to…
kuceram
  • 3,795
  • 9
  • 34
  • 54
0
votes
1 answer

GORM - MongoDB does not save an item on a parent class set

Here are the domain classes class Settings { static constraints = { uid(nullable: false, unique: true) data() } static hasMany = [items: Item] Map data } class Item{ static constraints = { name() …
Shlomi Schwartz
  • 8,693
  • 29
  • 109
  • 186
0
votes
2 answers

Import domain in constraints

I have 2 domain classes class a { String name static constraints = { name unique:true } } class b { String description } and in domain class b I want to call class a import a class b { String description static…
rsijaya
  • 159
  • 2
  • 14
0
votes
1 answer

Testing criteria in Grails 2.2

One of the reasons we are moving from Grails 1.3.7 to 2.2 is for the ability to unit test our (many) criteria. And the first thing we have run into with criteria testing is this: Property [nightly.id] is not a valid property of class…
Clark Wright
  • 741
  • 1
  • 6
  • 13
0
votes
1 answer

how to create custom queries in grails domain

Is there a way to create a query in a grails domain that always returns the records that have a specific criteria? For example: Class Person { String firstname String lastname } Now instead of saying Person.findByFirstname("Bart") all over…
birdy
  • 9,286
  • 24
  • 107
  • 171
0
votes
1 answer

multiple domain class with belongsTo relationship

I have 3 classes as per below... Class A { E objE; } Class B { E objE; } Class E { E objE; belongsTo:[ a : A, b : B ] static constraints = { a nullable: true b…
Ashish Jani
  • 295
  • 3
  • 14