grails-domain-class

Grails 3.1.0.M2 Database Reverse Engineering

感情迁移 提交于 2019-12-23 02:25:13
问题 Need of help. I am new to Grails, My question is How to do db-reverse-engineer.? I did it in Grails 2.5.1 but I am struggling with Grails 3.1.0.M2 version. Thanks in advance. 回答1: There's no plugin for Grails 3. I started to convert the older one but it's more work than I was expecting because it has to work with Hibernate 4, and the old plugin only works with Hibernate 3. But the generated files wouldn't be any different in Grails 3 than in Grails 2 since GORM has stayed rather consistent.

How to set formula in grails domain class?

烈酒焚心 提交于 2019-12-22 13:04:50
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

How to set formula in grails domain class?

帅比萌擦擦* 提交于 2019-12-22 13:03:08
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

How to set formula in grails domain class?

心不动则不痛 提交于 2019-12-22 13:03:06
问题 I am trying to write formula in my domain class which helps me in creating criteria. class MyClass { //some fields Date appointmentTime String ddmmyy int year int month int day static transients = [ 'ddmmyy', 'year', 'month', 'day' ] static mapping= { ddmmyy formula('DATE_FORMAT(appointmentTime)') year formula('YEAR(appointmentTime)') month formula('MONTH(appointmentTime)') day formula('DAYOFMONTH(appointmentTime)') } } Whenever I am trying to use this fields in my criteria it throws error i

Grails - sort by the domain relation attribute (using createCriteria())

。_饼干妹妹 提交于 2019-12-22 09:22:43
问题 I have two domain classes with 1:n relationship: import Action class Task { Action actionParent String taskName } and class Action { String actionName } I have the list of Tasks where I have the column "Action name", I would like to sort this column by Action.actionName. Now I'm using the createCriteria() method [I need to use it because I have more logic for filtering and sorting...], but I'm able to sort only by "Action.id". This method looks like: def criteria = Task.createCriteria();

How can I use embedded GORM classes in Grails?

元气小坏坏 提交于 2019-12-22 08:57:50
问题 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 = { name(nullable: false, blank: false) } static embedded = ['homeAddress', 'workAddress'] } class ScafAddress { String number String code } The controller just uses scaffolding: package grailscompositiontest class ScafPersonController { static scaffold = true } Unfortunately this

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

孤街醉人 提交于 2019-12-22 05:19:33
问题 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 these three values will be listed in combo box when using dynamic scaffolding for Person controller. Here I just wanted to know if there is such feature in Grails framework? If such feature exists , then how can I use it? 回答1: From the documentation http://grails.org

Grails: How to query objects in many to many mapping?

北慕城南 提交于 2019-12-22 04:06:14
问题 Hello I have the follwing domain classes. class Student { int age static hasMany = [courses:Course] } class Course { String name static hasMany = [students:Student] } I want to find the Students taking Course (with id 1), with age 7. Could I do that with dynamic finder or criteria builder or HQL? I do not want to do following as it load all students so inefficient: def course = Course.get(1); course.students.findAll{ it.age == 7 } 回答1: def studs = Student.withCriteria { eq('age', 7) courses {

Inheritance or Service for common Domain methods?

寵の児 提交于 2019-12-22 00:26:05
问题 I have some methods that are common across a few of my domain classes. I want to reduce the amount of replicated code and two solutions came to mind: 1) Put the common methods in a baseDomain class and inherit the methods from it in my domains 2) Put the common methods in a commonDomainMethodService which I can import into my domains I am thinking I should leave inheritance alone unless the domains share common properties, but I'm not sure. Is one of these methods more beneficial than the

Grails, how to find by a record by its foreign key

…衆ロ難τιáo~ 提交于 2019-12-21 12:33:52
问题 I have two domains that are a part of a one-to-many relations ship. I was wondering how i can query the child for the parents FK? bellow is the psuedo-code for parent/child Parent: class AlumProfile { String firstName String lastName static hasMany = [alumLanguage : AlumLanguage] static mapping = { cache true id generator: 'assigned' columns { firstName type:'text' lastName type:'text' } // } static constraints = { firstName (nullable:true) lastName (nullable:true) } } Child: class