gorm

Proper Implementation of clone() For Domain Classes to duplicate a Grails domain instance

时间秒杀一切 提交于 2019-12-29 05:31:07
问题 I have several domain classes for which the user interface includes a "duplicate" command. As part of the implementation of those commands, I have implemented clone() methods in the corresponding domain classes. I have been trying to correct my bad habit of improperly implementing clone() (in general) based on use of " new " rather than "super.clone()," so as soon as I thought about doing the same for my Grails domain classes, I wondered how using super.clone() to obtain a clone might

How to configure Grails 3.1.1 to use Hibernate 5

余生颓废 提交于 2019-12-29 01:49:07
问题 How do I make Grails 3.1.1 user Hibernate 5? The following actions report Hibernate version 4.3.11.Final: In Grails 3.1.1 grails create-app hello311 edit BootStrap.groovy as shown below grails run-app Console shows: Hibernate version is: 4.3.11.Final class BootStrap { def init = { servletContext -> println "Hibernate version is: ${org.hibernate.Version.getVersionString()}" } def destroy = {} } My build.gradle is unedited. The create-app command resulted in the following build.gradle file:

Column type in grails not working

馋奶兔 提交于 2019-12-25 08:49:49
问题 This is my model. class Review { String review Date date int numberOfComments String status static belongsTo = [game:Game, user:User] static hasMany=[comment:Comment] static mapping ={ numberOfComments defaultValue: "0" review type: 'text' } static constraints = { } when I inputted 400 character text it generated this error I don't know why the review type: 'text' is not working. can someone help? 回答1: In fact grails GORM sometimes have problems with updating column types, especially if they

Using assigned ID for domain object in Grails 2.0

邮差的信 提交于 2019-12-25 08:48:09
问题 We are using Grails with a legacy database and we need to control how ID's get assigned to domain objects. We have tried: id column: "sco_id", generator:'assigned' but we get the exception: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1 we have also tried to create a custom ID generator: public class ScoIdGenerator implements IdentifierGenerator { public Serializable generate(SessionImplementor session, Object object) { /*Generate ID here*/ return

Accessing the data in db via Domain class in Controller via grails testing

筅森魡賤 提交于 2019-12-25 08:43:06
问题 def index() { //println params String params_key =params['key'] def c = get_value(params_key) def resp = ['key': params_key, 'value':c] render resp as JSON } private static hash_conv(String value) { def matches = Eval.me(value.replace(':','').replace('{','[').replace('=>',':').replace('#','//').replace('}',']')) return matches } private get_value(String key, default_value=null){ def app_preferences = get_preferences() def result = app_preferences[key] if (result == null) { result = default

Which Dynamic methods are not included in Grails Unit Tests?

妖精的绣舞 提交于 2019-12-25 06:50:04
问题 Reading the documentation on Grails Unit testing I came across the following: In Grails you need to be particularly aware of the difference between unit and integration tests because in unit test Grails does not inject any of the dynamic methods present during integration tests at runtime. ^ Grails 9.1 Unit Testing Documenation And with this I'm assuming the missing injected methods refer to: the getBy* , .save() methods from GORM and Hibernate Is there anything else that is dynamically

Trying out neo4j grails plugin, but it does not mach the docs

让人想犯罪 __ 提交于 2019-12-25 06:37:17
问题 I am trying neo4j plugin and I created a simple test as follows: package com.iibs.graph import groovy.util.GroovyTestCase import com.iibs.graph.Node public class NodeTests extends GroovyTestCase { void testCRUD() { Node.deleteAll(Node.list()) Node node = new Node(name: "Name") node.save(flush: true, failOnError: true) Node found = Node.findByName("Name") assert found instanceof Node assert found.getName() == "Name" assert found.node instanceof org.neo4j.graphdb.Node } } Based on the

Seemingly Random 1=1 where clause generated by GORM's where closure

≡放荡痞女 提交于 2019-12-25 05:24:07
问题 Sample Program With Problem: https://github.com/HybridProgrammer/GormOneIsOneError Problematic GORM Code def query = UserData.where { ( teams { id in me.getAuthorities().id } && status { isOpen == true } ) || ( owner == me && status { isOpen == true } ) } Summary of the Problem The generated SQL query occasionally produces a where clause containing 1=1 when I would expect to see teams_alia1_.id in (?) Detailed Description of the Problem I wrote two integration test to illustrate this problem:

GORM how to ensure uniqueness of related objects property

ε祈祈猫儿з 提交于 2019-12-25 03:57:29
问题 I'm trying to get my head around GORM and relational mapping. The relationships are working fine but there is one problem. I can't seem too ensure that every MailAddress added to MailingList has a unique address. What would be the must efficient way to do this? Note: There is no unique constraint on MailAddress.address . Identical addresses can exist in the same table. class MailAddress { String name String email static belongsTo = MailingList static constraints = { name blank:true email

Remove simpledb mapWith by meta programming in dev mode

≡放荡痞女 提交于 2019-12-25 02:43:24
问题 I am using simpleDB GORM with my grails application, though simpledb is great its a huge drag while in development mode, every click takes few seconds resulting in not so rapid development. From what I understand simpleDB comes into action only if domain class has following two lines in code String id static mapWith = "simpledb" So, my question is, is it possible to remove/hide these two declaration on the fly from domain classes depending on some kind of flag? Same question asked differently