gorm

Unable to add Neo4j GORM plugin to a Grails project

僤鯓⒐⒋嵵緔 提交于 2019-12-24 04:26:33
问题 I want to use Neo4j graph database for my Grails project. I created a new Grails project (i'm using Intellij Ultimate Edition). The app runs fine. When i try to add the Neo4j dependency (compile ":neo4j:2.0.0-M02") in my BuildConfig.groovy and try to update the project I get the following errors in the console: Error | Resolve error obtaining dependencies: Could not find artifact org.neo4j:neo4j-jdbc:jar:2.0.2 in grailsCentral (https://repo.grails.org/grails/plugins) (Use --stacktrace to see

How do I save GORM objects with multiple many-to-one relationships?

佐手、 提交于 2019-12-24 03:59:09
问题 Let's say I have the following hierarchy of domain classes. class School { String name static hasMany = [teachers: Teacher, students: Student] } class Teacher { String name static belongsTo = [school: School] static hasMany = [students: Student] } class Student { String name static belongsTo = [school: School, teacher: Teacher] } I tried two different ways to save a school, teacher, and student. Attempt 1: def school = new School(name: "School").save() def teacher = new Teacher(name: "Teacher

Specifying field size of Map collection in grails DOM

て烟熏妆下的殇ゞ 提交于 2019-12-24 03:48:10
问题 I have a Grails 1.3.7 domain class that is declared like this: class Document { String url Map metadata = new HashMap() static constraints = { url(nullable:false, blank: false, maxSize: 2048) metadata() } } The schema that is generated looks like this: +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+----------------+ | id | bigint(20) | NO | PRI | NULL | auto_increment |

Unit testing Grails domains that (over?) extend a base class that uses services

坚强是说给别人听的谎言 提交于 2019-12-24 03:41:48
问题 So, I have a base class that I want to extend most (but not all) of my domain classes from. The goal is that I can add the six audit information columns I need to any domain class with a simple extends . For both creation and updates, I want to log the date, user, and program (based on request URI). It's using a Grails service (called CasService) to find the currently logged on user. The CasService then uses Spring Security and a database call to get the relevant user information for that

Unit testing Grails domains that (over?) extend a base class that uses services

ε祈祈猫儿з 提交于 2019-12-24 03:41:20
问题 So, I have a base class that I want to extend most (but not all) of my domain classes from. The goal is that I can add the six audit information columns I need to any domain class with a simple extends . For both creation and updates, I want to log the date, user, and program (based on request URI). It's using a Grails service (called CasService) to find the currently logged on user. The CasService then uses Spring Security and a database call to get the relevant user information for that

Grails 2.0.0.M2 - cascade save problem

不问归期 提交于 2019-12-24 03:29:13
问题 I have two simple domain classes: class Name { String firstName String lastName static belongsTo = [person: Person] } class Person { Name name String comment } and service with two methods: class PersonService { Person newPerson() { def person = new Person() person.name = new Name() person } Person savePerson(Person person) { person.save() } } Now if I create a new Person with PersonService.newPerson() and then try to save it using savePerson() method using grails 1.3.7 everything works fine.

In Grails is there something in domain class like onLoad()?

佐手、 提交于 2019-12-24 02:42:11
问题 Guys, I have a following domain class: class Product { String name, String productRecord, static transients = ['productRecord'] } productRecord is a field which is generated automatically based on the id of the Product instance. So I've been thinking, is there a place which will be automatically called when a domain instance is load to generate the productRecord number? What's the best way to do that? 回答1: You can probably leverage the built-in Domain Events: GORM supports the registration of

GORM auto flush when request ends without calling save

余生颓废 提交于 2019-12-24 00:36:17
问题 I have prepared simple controller action to test behaviour related with unexpected commiting changes to datatbase: def testSimple() { Product p = Product.findById(1); p.name = "test doneee" //p.save flush:true respond p } The changes are persisted in database even the save() has not been called. How to avoid saving entity without calling save() ? 回答1: Grails registers an OpenSessionInView interceptor which starts a Hibernate Session and the beginning of each request, and flushes and closes it

Does the multiple datasource feature of Grails 2.0 support relations?

六月ゝ 毕业季﹏ 提交于 2019-12-24 00:19:37
问题 I'm trying to support some legacy tables and I was able to create a domain that uses a separate datasource of those legacy tables. However, when I try to use that domain from the separate datasource in a hasMany , it fails. Is it possible to relate hasMany to a domain on a different datasource? 回答1: Unfortunately you can not have GORM automatically manage the association across multiple datasources. However, that said you can quite easily write the code that will accomplish what you are

Grails 2 abstract domain inheritance issue

好久不见. 提交于 2019-12-23 18:35:21
问题 The following is not working for me when using abstract (or non-abstract for that matter) inheritance in Grails. Very quickly, my inheritance is as follows: abstract BaseClass { ... } SomeClass extends BaseClass { ... } SomeOtherClass extends BaseClass { ... } And then in another domain object: ThirdClass { ... BaseClass baseProperty ... } But now, when I try to set that property to either a SomeClass or SomeOtherClass instance, Grails compains: ERROR util.JDBCExceptionReporter - Cannot add