Showing posts with label problem. Show all posts
Showing posts with label problem. Show all posts

Monday, February 9, 2009

GORM 1 to 0..1 relationship issue

Recently I wanted to create one-to-one relationship (1 to 0..1) not pure 1 to 1. But unfortunately faced with the problem. Let's review it in details (entity A can have association with zero or only one entity B):
class A {
B b

static constraints = {
b(nullable: true)
}

}

class B {
A a

static belongsTo = [A]
}

Grails generated the database schema in such way: table A has column b_id (as it has to be), but it cannot be nullable. As You can see for 1 to 0..1 relationship this is a wrong behavior. I posted question on Nabble forums (as I recommended to everyone:) ) and received answer that mentioned problem will be fixed in Grails 1.1. For more details visit appropriate forum post.

Saturday, February 7, 2009

First post

Hello everyone,

I'm Java developer who moved to Groovy/Grails recently.
In my blog I will post common simple issues and their solution concerning using Groovy and Grails. I hope that someone will find my posts useful and save time solving common problems.

Best regards.