GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / orm / hibernate / UnidirectionalMapOneToManyUpdateTests.groovy
blob384cddc0790aba09b6b8a5bfbdae0cb75e106d21
1 /**
2 * @author Graeme Rocher
3 * @since 1.0
4 *
5 * Created: Dec 3, 2007
6 */
7 package org.codehaus.groovy.grails.orm.hibernate
8 class UnidirectionalMapOneToManyUpdateTests extends AbstractGrailsHibernateTests {
10 protected void onSetUp() {
11 gcl.parseClass '''
12 class Customer
14 Long id
15 Long version
16 Map orders
17 static hasMany = [ orders : Order]
18 String email
19 String password
21 class Order
23 Long id
24 Long version
25 String number
26 Date date = new Date()
28 static mapping = {
29 table "`order`"
32 '''
37 void testAssociateOneToMany() {
38 def custClass = ga.getDomainClass("Customer").clazz
39 def orderClass = ga.getDomainClass("Order").clazz
41 assert custClass.newInstance(email:"foo@bar.com", password:"letmein").save()
42 assert orderClass.newInstance(number:"12345").save(flush:true)
44 session.clear()
46 def cust = custClass.get(1)
47 def order = orderClass.get(1)
49 cust.orders = [order1:order]
52 cust.save(flush:true)
54 session.clear()
56 cust = custClass.get(1)
58 assertEquals 1, cust.orders.size()
59 assert cust.orders.order1