gorm

How to limit the size of association in grails?

醉酒当歌 提交于 2019-12-25 01:45:40
问题 I have a grails domain class as below : class Order { String orderId = 'OD' + System.nanoTime().toString() Date orderedDate String itemName List bids; static hasMany = [ bids: Bid ;likedUsers: User,] static belongsTo =[owner:User] } class Bid { Integer amount User bidedUser static belongsTo = [Order] } class User { String username String password String emailId List orders static hasMany = [orders:Order] } What I am trying to do is , to query for an order with bits with maxResult of 10 as

Grails v3.3.9 GORM defect - one to many with mappedBy, updates can be made to fail

☆樱花仙子☆ 提交于 2019-12-24 19:29:55
问题 Grails v3.3.9 - impacts live/dev and integration test My scenario is that I had an integration test that kept failing when building a manually created record and one found from DB, but works if you link two manually created records in the test. I have been trying a thousand tweaks and make sure GORM was doing what it said in docs. I've pared my code right back and built something simpler that looks structurally like my real stuff but is based on the Airport/Flights model in the GORM user

NoClassDefFoundError: org/grails/compiler/gorm/GormEntityTransformation

你说的曾经没有我的故事 提交于 2019-12-24 15:25:39
问题 I'm currently upgrading a rather large application to mongodb:5.0.1.RELEASE from mongodb:3.0.2 and I'm receiving the following exception when attempting to grails package Caused by: java.lang.NoClassDefFoundError: org/grails/compiler/gorm/GormEntityTransformation at org.codehaus.groovy.grails.compiler.gorm.GormTransformer.performInjection(GormTransformer.java:69) at org.codehaus.groovy.grails.compiler.gorm.GormTransformer.performInjectionOnAnnotatedClass(GormTransformer.java:78) at org

NoClassDefFoundError: org/grails/compiler/gorm/GormEntityTransformation

时光怂恿深爱的人放手 提交于 2019-12-24 15:17:49
问题 I'm currently upgrading a rather large application to mongodb:5.0.1.RELEASE from mongodb:3.0.2 and I'm receiving the following exception when attempting to grails package Caused by: java.lang.NoClassDefFoundError: org/grails/compiler/gorm/GormEntityTransformation at org.codehaus.groovy.grails.compiler.gorm.GormTransformer.performInjection(GormTransformer.java:69) at org.codehaus.groovy.grails.compiler.gorm.GormTransformer.performInjectionOnAnnotatedClass(GormTransformer.java:78) at org

grails beforeDelete with many-to many relation

。_饼干妹妹 提交于 2019-12-24 13:30:41
问题 I have 2 domain class with a many to many relationship. When I delete the entity that belongs to the other, I have to remove the relation before in order to avoid a foreign key error. I would like to put this code in the beforeDelete event, but I obtain a problem with optimistc locking. This is the code of the domain classes: class POI { static belongsTo = [Registration]; static hasMany = [registrations: Registration] def beforeDelete = { def poiId = this.id POI.withNewSession { session ->

Gorm equivalent for SQL

天涯浪子 提交于 2019-12-24 09:58:02
问题 Simple one - what is the best way in Grails/Gorm to get the same effect as this SQL query: SELECT YEAR(date) as SalesYear, MONTH(date) as SalesMonth, SUM(Price) AS TotalSales FROM Sales GROUP BY YEAR(date), MONTH(date) ORDER BY YEAR(date), MONTH(date) 回答1: The executeQuery method of a domain class allows you to run HQL queries. If you look at some examples, you will notice that the Hibernate Query Language remembers a lot SQL, but is object-oriented. From the Grails docs: The executeQuery

Grails 3.1.1 - Dirty checking not working when model class extends another groovy class

痴心易碎 提交于 2019-12-24 09:27:58
问题 I have a domain class which extends another groovy class with same name but in different package in a different library. The problem is when I modify instances on the domain class, it is not marked as dirty & hence changes are not persisted. I have read that grails 3 release has some enhancements to dirty checking & this could be a bug or I am missing something. New objects are saved properly without any issues, I have used isDirty() method on modified domain object as well as modified

Get detached domain entity in grails

别来无恙 提交于 2019-12-24 05:38:06
问题 I want to get a domain entity in grails in detached state when there is another domain entity for same id in same method. I followed this How do you disconnect an object from it's hibernate session in grails? as a way to get a detached domain entity in grails. def id = 23L; def userInstance = User.get(id) def oldInstance = User.get(id).discard() userInstance.properties = params userInstace.save(flush:true) // Now, I want to compare properties of oldInstance and userInstance // But I get null

Grails error: table or view does not exist

会有一股神秘感。 提交于 2019-12-24 05:19:07
问题 When ever I start my Grails application, I get these errors for all my domain classes. ERROR hbm2ddl.SchemaExport - HHH000389: Unsuccessful: drop table domain_class cascade constraints ERROR hbm2ddl.SchemaExport -ORA-01031: insufficient privileges and then ERROR hbm2ddl.SchemaExport -ORA-00942: table or view does not exist I am using in-memory database for the application and my DataSource.groovy has this in it: dataSource { pooled = true driverClassName = "org.h2.Driver" username = "sa"

Multiple <g:select> in one GSP and multiple params in HQL inside controller

放肆的年华 提交于 2019-12-24 04:44:30
问题 GSP <html> <head> <g:javascript src="jquery-1.10.2.min.js"/> <g:javascript src="prototype.js"/> </head> <body> <form> <g:select from="['AFFILIATES', 'SEO', 'SEM','DISPLAYADS']" name="mv" onchange="${remoteFunction( controller:'Pgtyp', action:'ajaxGetMv', params:'\'mv=\' + escape(this.value)', onSuccess: 'printpgtyp(data)')}" ></g:select> </form> <script> function printpgtyp(data) { console.log(data); } </script> </body> </html> CONTROLLER package marchmock2 import grails.converters.* import