GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / orm / hibernate / BidirectionalListPersistTests.groovy
blobcb87473524bbd9b83035e14abe5c340b762db305
1 package org.codehaus.groovy.grails.orm.hibernate
3 import org.hibernate.Session
5 /**
6 * @author Graeme Rocher
7 * @since 1.0
9 * Created: Mar 12, 2008
11 class BidirectionalListPersistTests extends AbstractGrailsHibernateTests{
13 protected void onSetUp() {
14 gcl.parseClass '''
15 class TestFaqSection
17 Long id
18 Long version
19 String title
20 List elements
21 static hasMany = [elements:TestFaqElement]
23 class TestFaqElement
25 Long id
26 Long version
27 String question
28 String answer
29 TestFaqSection section
31 '''
34 void testListPersisting() {
35 def sectionClass = ga.getDomainClass("TestFaqSection")
36 def section = sectionClass.newInstance()
38 section.title = "foo"
39 def element = ga.getDomainClass("TestFaqElement").newInstance()
40 element.question = "question 1"
41 element.answer = "the answer"
42 section.elements = [element]
46 session.save section
48 session.flush()
50 session.clear()
52 section = session.get(sectionClass.getClazz(),1L)
54 assert section
55 assertEquals 1, section.elements.size()