grails-domain-class

Class 'myClassName' already exists in package 'myPackageName'

非 Y 不嫁゛ 提交于 2021-02-18 12:07:08
问题 I suddenly started facing a strange issue while working on my Grails application using IntelliJ. I have different domain classes and some other classes under src/groovy . When I open a class file to make some changes, I get an error that this class already exists in package which I don't have. I tried to rename the class using refactor but after that I still get the same error. Can anybody suggest what's wrong here or if I did something wrong? 回答1: Try to "Clear" you project and build again.

Class 'myClassName' already exists in package 'myPackageName'

余生长醉 提交于 2021-02-18 12:06:02
问题 I suddenly started facing a strange issue while working on my Grails application using IntelliJ. I have different domain classes and some other classes under src/groovy . When I open a class file to make some changes, I get an error that this class already exists in package which I don't have. I tried to rename the class using refactor but after that I still get the same error. Can anybody suggest what's wrong here or if I did something wrong? 回答1: Try to "Clear" you project and build again.

Grails GORM class with @GrailsCompileStatic annotation shows in the static mapping closure table, version, autoTimestamp as unresolved symbol

烈酒焚心 提交于 2020-07-15 09:26:46
问题 References: https://youtrack.jetbrains.com/issue/IDEA-206196 https://youtrack.jetbrains.com/issue/IDEA-207415?_ga=2.103698112.1724644326.1581075934-247190714.1566820331 package de.equeo.requestcode import grails.compiler.GrailsCompileStatic @GrailsCompileStatic class Feature { String name static mapping = { table 'rq_feature' version false autoTimestamp false } } This results in the error in the IDE only (works fine in grails run-app or while compiling): 回答1: Instead of doing that you can use

Grails: Defining a JSON custom marshaller as static method in domain

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-14 19:21:27
问题 I'm using Grails 2.4.2. As can be seen here: https://grails.org/Converters+Reference You can create a static method in your domain with your custom marshaller to render the JSON in the controller. Like that: Domain: // a class to output in JSON package com.sample class User { String login String passwd // JSON definition of the User object static { grails.converters.JSON.registerObjectMarshaller(User) { return [ login: it.login ] } } Then in your controller: def user = new User(login:'bob',

Grails integration test - domain object equality

北城余情 提交于 2020-01-05 08:17:53
问题 Setting up some integration tests, I'm having issues with domain class equality. The equality works as expected during normal execution, but when testing the Service methods through an integration test, the test for equality is coming back false. One service (called in the setUp() of the Test Case) puts a Domain object into the session SomeService { setSessionVehicle(String name) { Vehicle vehicle = Vehicle.findByName(name) session.setAttribute("SessionVehicle", vehicle) } getSessionVehicle()

How to handle errors that occur in @BindUsing annotation closure

て烟熏妆下的殇ゞ 提交于 2020-01-04 01:36:09
问题 I have a property with custom data binding like this: class User { // Custom data binding for the image @BindUsing({ obj, source -> def imageFile = source['image'] if (imageFile && imageFile.size > 0) { Document image = obj.image ?: new Document() image.setFile(imageFile) if(!image.save()) { throw new Exception('Non localizable message') } return image } }) Document image ... } If an exception is thrown (like in my example) it is converted to a ValidationException with always the same generic

Grails Domain Class : hasOne, hasMany without belongsTo

拥有回忆 提交于 2020-01-02 03:30:09
问题 I am new to Grails. Can I use "hasOne" or "hasMany" without using "belongsTo" to another domain-class? Thanks in advance. 回答1: Yes, you can. See examples in Grails doc: http://grails.org/doc/2.3.8/guide/GORM.html#manyToOneAndOneToOne hasMany (without belongsTo) example from the doc: A one-to-many relationship is when one class, example Author, has many instances of another class, example Book. With Grails you define such a relationship with the hasMany setting: class Author { static hasMany =

Grails: map mysql field of type enum to domain class

橙三吉。 提交于 2020-01-01 12:09:10
问题 How can I map a mysql field of type enum to a grails domain class? I'm using an existing (legacy) mySQL database with grails v.2.0.3. I'm getting an error for Wrong column type: failed; nested exception is org.hibernate.HibernateException: Wrong column type in facilities.ost_fac_syslog for column log_type. Found: enum, expected: varchar(255) The SQL field is defined as: mysql> describe ost_fac_syslog; +------------+---------------------------------+------+-----+-------------------- | Field |

How can I duplicate a domain object in Grails?

自作多情 提交于 2019-12-30 18:24:20
问题 I want to make a copy of a domain object. What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do this... In Rails there is a simple way to do this: #rails < 3.1 new_record = old_record.clone #rails >= 3.1 new_record = old_record.dup Is there any equivalent in Grails? 回答1: There is not. It has been requested http://jira.grails.org/browse/GRAILS

How can I duplicate a domain object in Grails?

自作多情 提交于 2019-12-30 18:22:31
问题 I want to make a copy of a domain object. What is the simplest way to accomplish this? I realize I could create a new record, and then iterate over each of the fields copying the data field-by-field - but I figured there must be an easier way to do this... In Rails there is a simple way to do this: #rails < 3.1 new_record = old_record.clone #rails >= 3.1 new_record = old_record.dup Is there any equivalent in Grails? 回答1: There is not. It has been requested http://jira.grails.org/browse/GRAILS