gorm

Grails 3.1.0.M2 Database Reverse Engineering

你。 提交于 2019-12-08 23:11:30
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. 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. Since the plugin is only used at build time, and often only once or at most a few times, I recommend that you

GORM doesn't handle mapping of associations which have a further association in their composite primary key

半世苍凉 提交于 2019-12-08 20:55:31
I'm trying to map existing tables in a GORM/Grails app. Most of the tables have composite primary keys (not my choice). I'm finding that when I map an association to a class (parent of a child) where the composite key of the parent class contains an association to a class with a composite key also (grandparent), GORM doesn't bother to check the mapping of the grandparent class and subs in a non-composite key. Child class Child implements Serializable { Parent parent String name belongsTo= [parent: Parent] static mapping= { id(composite: ['parent', 'name']) } } Parent class Parent implements

Use of ENUMs in Grails Domain Class

给你一囗甜甜゛ 提交于 2019-12-08 19:23:35
问题 There are a few examples of ENUM on Grails (here in SO as well), but I am not being able to get the desired results. Solutions include 1) By having the ENUM in a separate class under the src/groovy Domain Class class Offer { PaymentMethod acceptedPaymentMethod .. } src/groovy PaymentMethod public enum PaymentMethod { BYBANKTRANSFERINADVANCE('BANKADVANCE'), BYINVOICE('ByInvoice'), CASH('Cash'), CHECKINADVANCE('CheckInAdvance'), PAYPAL('PayPal'), String id PaymentMethod(String id) { this.id =

Grails , how do I get an object NOT to save

二次信任 提交于 2019-12-08 16:37:57
问题 I am new to grails and trying to create a form which allows a user to change the email address associated with his/her account for a site I am creating. It asks for the user for their current password and also for the new email address they want to use. If the user enters the wrong password or an invalid email address then it should reject them with an appropriate error message. Now the email validation can be done through constraints in grails, but the password change has to match their

cascade delete with many-to-many mapping in Grails

扶醉桌前 提交于 2019-12-08 11:44:33
问题 I have problem about many-to-many mapping. [Case] Account owns Community(owner) Community has many Account(members) When I delete instance of Community, owner account is also delete. I don't expect owner account to be removed. My mapping is wrong? [Domain Class] class Account { String name static hasMany = [communities: Community] static belongsTo = [Community] } class Community { String name Account owner static hasMany = [members: Account] } [TestCode] def admin = new Account(name: 'admin')

Is it possible in grails to disable persistence of a domain class dynamically with inheritance

被刻印的时光 ゝ 提交于 2019-12-08 09:10:13
问题 My question is related to/or identical to Is it possible in grails to disable persistence of a domain class? I am using grails 2.2.1 where I tried to turn off a domain class by putting static mapWith = "none" gorm creates the database table, and calling .save() will actually put an entry to the database. So the mapWith flag did nothing for me. I also cannot find any documentation regarding the mapWith flag. Is there a replacement in Grails 2? Update on sept 16 with code package test class

Get a list of all objects grails is planning to magically save

旧巷老猫 提交于 2019-12-08 08:47:30
If I make a domain object in a controller and don't call .save() , Grails will do it for me automatically at some point. I am creating lots of domain objects without planning to save all of them and getting 'references an unsaved transient instance' exceptions when my service exits. How would I get a list of all objects that Grails will try to save when the controller/service exits so that I could prevent some of them from being saved? You're better off retrieving instances that you know you will edit but don't want persisted with the read method instead of get . Using read doesn't make it

GORM doesn't handle mapping of associations which have a further association in their composite primary key

拜拜、爱过 提交于 2019-12-08 06:35:56
问题 I'm trying to map existing tables in a GORM/Grails app. Most of the tables have composite primary keys (not my choice). I'm finding that when I map an association to a class (parent of a child) where the composite key of the parent class contains an association to a class with a composite key also (grandparent), GORM doesn't bother to check the mapping of the grandparent class and subs in a non-composite key. Child class Child implements Serializable { Parent parent String name belongsTo=

Grails: Is it possible to prevent a domain class instance from being persisted?

断了今生、忘了曾经 提交于 2019-12-08 04:50:32
问题 I want to create an (one) instance of a Domain class (which, as expected, has a GORM interface to my database) and only use it as a container to pass data around, like a Map object. I want to make absolutely sure that my instance is never going to get persisted in the database. I'm afraid that GORM, with all its cleverness, will somehow manage to save it in the database behind the scene even without an explicit call to save() . Is there a way to specify a "do not persist this" clause when

get mapWith static domain field value from GrailsDomainClass grails

删除回忆录丶 提交于 2019-12-08 04:36:10
问题 How can I get mapWith property of a domain class? I tried domainClass.mapWith as it's a static property of domain class.It didn't work. I also tried mappedBy but it's a different context. Any idea on how can i get mapWith value from GrailsDomainClass Below is my domain:- public class Ticket { String id List<Long> productInstanceId static hasMany = [productInstanceId:Long] static mapWith = "none" } 回答1: If you are doing a direct check on a particular domain then you can fetch the static