2 * Tests a many-to-many and one-to-one relationship used together
4 * @author Graeme Rocher
7 * Created: Oct 12, 2007
9 package org
.codehaus
.groovy
.grails
.orm
.hibernate
11 import org
.codehaus
.groovy
.grails
.commons
.GrailsDomainClass
13 class ManyToManyAndOneToOneTests
extends AbstractGrailsHibernateTests
{
15 protected void onSetUp() {
20 static belongsTo = Author
23 static hasMany = [authors:Author]
24 static mappedBy = [authors:"books"]
32 static hasMany = [books:Book]
33 static mappedBy = [books:"authors"]
41 GrailsDomainClass bookClass
= ga
.getDomainClass("Book")
42 GrailsDomainClass authorClass
= ga
.getDomainClass("Author")
44 assertTrue authorClass
.getPropertyByName("bookOther").isOneToOne()
45 assertTrue authorClass
.getPropertyByName("books").isManyToMany()
46 assertEquals
"authors",authorClass
.getPropertyByName("books").otherSide
.name
47 assertFalse authorClass
.getPropertyByName("bookOther").isBidirectional()
50 assert bookClass
.getPropertyByName("authors").isManyToMany()
51 assertEquals
"books",bookClass
.getPropertyByName("authors").otherSide
.name