gorm

Grails query not using GORM

人走茶凉 提交于 2019-11-27 01:39:10
问题 What is the best way to query for something without using GORM in grails? I have query that doesn't seem to fit in the GORM model, the query has a subquery and a computed field. I posted on stackoverflow already with no response so I decided to take a different approach. I want to query for something not using GORM within a grails application. Is there an easy way to get the connection and go through the result set? 回答1: In a service or controller, you can add a dependency injection for the

Retrieving a list of GORM persistent properties for a domain

╄→гoц情女王★ 提交于 2019-11-27 00:28:12
问题 What's the best/easiest way to get a list of the persistent properties associated with a given GORM domain object? I can get the list of all properties, but this list contains non-persistent fields such as class and constraints . Currently I'm using this and filtering out the list of nonPersistent properties using a list I created: def nonPersistent = ["log", "class", "constraints", "properties", "errors", "mapping", "metaClass"] def newMap = [:] domainObject.getProperties().each { property -

Found shared references to a collection org.hibernate.HibernateException

我怕爱的太早我们不能终老 提交于 2019-11-26 22:18:25
I got this error message: error: Found shared references to a collection: Person.relatedPersons When I tried to execute addToRelatedPersons(anotherPerson) : person.addToRelatedPersons(anotherPerson); anotherPerson.addToRelatedPersons(person); anotherPerson.save(); person.save(); My domain: Person { static hasMany = [relatedPersons:Person]; } any idea why this happens ? ChssPly76 Hibernate shows this error when you attempt to persist more than one entity instance sharing the same collection reference (i.e. the collection identity in contrast with collection equality). Note that it means the

Found shared references to a collection org.hibernate.HibernateException

旧城冷巷雨未停 提交于 2019-11-26 08:15:21
问题 I got this error message: error: Found shared references to a collection: Person.relatedPersons When I tried to execute addToRelatedPersons(anotherPerson) : person.addToRelatedPersons(anotherPerson); anotherPerson.addToRelatedPersons(person); anotherPerson.save(); person.save(); My domain: Person { static hasMany = [relatedPersons:Person]; } any idea why this happens ? 回答1: Hibernate shows this error when you attempt to persist more than one entity instance sharing the same collection