GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / test / groovy / org / codehaus / groovy / grails / orm / hibernate / ClassHeirarchyInheritanceTests.groovy
blobe344506b9a74eee2785573dc116a4575c2b15a07
1 /**
2 * Class description here.
4 * @author Graeme Rocher
5 * @since 0.4
7 * Created: Jul 13, 2007
8 * Time: 9:24:42 AM
9 *
12 package org.codehaus.groovy.grails.orm.hibernate
14 class ClassHeirarchyInheritanceTests extends AbstractGrailsHibernateTests {
15 void testPolymorphicQuery() {
16 def carClass = ga.getDomainClass("Car").clazz
17 def alpha = ga.getDomainClass("Alpha").newInstance()
18 def fiatClass = ga.getDomainClass("Fiat")
19 def fiat = fiatClass.newInstance()
20 def ferrari = ga.getDomainClass("Ferrari").newInstance()
22 fiat.type = "cheap"
23 alpha.type = "luxury"
24 ferrari.type = "luxury"
26 fiat.save()
27 alpha.save()
28 ferrari.save()
30 def cars = carClass.findAll("from Car as c where c.type='luxury'")
31 assertEquals 2, cars.size()
33 def fiats = fiatClass.clazz.list()
35 assertEquals 1, fiats.size()
38 void onTearDown() {}
40 void onSetUp() {
41 gcl.parseClass('''
42 class Car { Long id;Long version;String type;}
43 class Alpha extends Car { }
44 class Fiat extends Car { }
45 class Ferrari extends Car { }
46 ''')