gorm

Persist a list of LocalDate with GORM

扶醉桌前 提交于 2020-01-06 16:19:22
问题 I'm trying to persist a list of joda LocalDate in grails. What I have right now is something like this: package com.publidirecta import org.joda.time.LocalDate class Evento { List <LocalDate> fechas = [] static hasMany = [fechas:LocalDate] } and I get the following error : MappingException: Missing type or column for column[fechas_persistent_local_date] on domain[Evento] referencing[org.jadira.usertype.dateandtime.joda.PersistentLocalDate] ->> 334 | innerRun in java.util.concurrent.FutureTask

Persist a list of LocalDate with GORM

為{幸葍}努か 提交于 2020-01-06 16:19:01
问题 I'm trying to persist a list of joda LocalDate in grails. What I have right now is something like this: package com.publidirecta import org.joda.time.LocalDate class Evento { List <LocalDate> fechas = [] static hasMany = [fechas:LocalDate] } and I get the following error : MappingException: Missing type or column for column[fechas_persistent_local_date] on domain[Evento] referencing[org.jadira.usertype.dateandtime.joda.PersistentLocalDate] ->> 334 | innerRun in java.util.concurrent.FutureTask

Grails FindBy* with an inteface property

穿精又带淫゛_ 提交于 2020-01-06 08:46:26
问题 I have a class like class Account { BigDecimal balance = 0 SortedSet transactions AccountOwner owner static constraints = { } static hasMany = [transactions:Transaction] } when I try to query the Account like def account = Account.findByOwner(user) I get this error | Failure: testSave(br.com.fisgo.financial.AccountControllerTests) | org.springframework.dao.InvalidDataAccessResourceUsageException: Cannot query [br.com.fisgo.financial.Account] on non-existent property: owner at org.grails

When does Grails assign an ID to an object?

≯℡__Kan透↙ 提交于 2020-01-06 06:55:18
问题 A Grails 2.3.4 application is connecting to an Oracle database using the following domain class: class Person { String name static mapping = { id column: "PERSON_ID", generator: "sequence", params: [sequence: 'person_seq'] } } The PersonController makes a call to a method in PersonService and it makes a call to UtilService . The method in UtilService being called has some logic based on wether this Person object is new: if (personInstance.id == null) { ... } What I have found is that the id

grails grom create criteria with many-to-many mapping

江枫思渺然 提交于 2020-01-06 04:41:26
问题 I have two domain classes: User and Book. class Book implements Serializable{ String bookName Timestamp createdDateTime Blob file static belongsTo = [User] static hasMany = [user :User] } I am able to add user in book using addToUser() method. But I am stuck in create criteria while applying filter in user. def query = Book.createCriteria(); def results = query.list () { eq("user",userObject) // not working since user field is a list of users. order("createdDateTime", "desc") } Please help me

How to inherit GORM mapping from non domain class?

假如想象 提交于 2020-01-05 10:32:09
问题 Permanently I have some tables and some hibernate classes with mapping annotations. And this classes have abstract superclass with mapping annotations also. But in this superclass there is no table association mapping. All tables are identified in the subclasses. I'm trying to migrate this mapping to GORM model. But all strategies: TablePerHierarchy and TablePerSubclass not approach for my case because all tables is created and can't be changed. I created superclass in the 'src/groovy

Remotefunction not working

谁说我不能喝 提交于 2020-01-05 09:22:43
问题 Below is my Pgtyp.groovy (domain class): package marchmock2 class Pgtyp { Date date_hour String mv String pagetype Integer visits Integer visits_ly Integer visits_lw String time_period String platform String device String browser static mapping = { table "pgtyp" version false date_hour column: "date_hour" mv column: "mv" pagetype column: "pagetype" visits column: "visits" visits_ly column:"visits_ly" visits_lw column:"visits_lw" time_period column:"time_period" platform column:"platform"

Hibernate: force get() to respect the data type of its parameter

一笑奈何 提交于 2020-01-05 07:18:11
问题 Setup: Grails 2.5.6 with Hibernate 4.3.10 I have a table with a string id. Thing is, its values are numeric strings, and this seems to mess up get() when I pass in a value such as "000000" . Domain class: class Term { static mapping = { id name: 'code', generator: 'assigned' version false code column: 'CODE' description column: 'DESC' } String code String description } Data looks like: CODE || DESC -------++--------------------------- 000000 || The Beginning of Time 201715 || Post Secondary

Hibernate: force get() to respect the data type of its parameter

假装没事ソ 提交于 2020-01-05 07:18:09
问题 Setup: Grails 2.5.6 with Hibernate 4.3.10 I have a table with a string id. Thing is, its values are numeric strings, and this seems to mess up get() when I pass in a value such as "000000" . Domain class: class Term { static mapping = { id name: 'code', generator: 'assigned' version false code column: 'CODE' description column: 'DESC' } String code String description } Data looks like: CODE || DESC -------++--------------------------- 000000 || The Beginning of Time 201715 || Post Secondary

Multiple many-to-many associations in one Grails domain class

做~自己de王妃 提交于 2020-01-05 01:10:10
问题 I am using Grails 3.0.6 and am struggling with a complicated and highly interconnected domain model. I have classes with multiple many-to-many associations to other classes and I am left with no choice but to have multiple belongsTo associations on at least one class. I am unable to figure out the syntax to represent this. My domain model was quite complicated, but I was able to reduce my problem to this simplified example: class Graph { static hasMany = [vertices: Vertex] } class OtherClass