Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 2.0.1
-
Component/s: Persistence
-
Labels:
-
Environment:Grails 2.0-BUILD-SNAPSHOT (18/11)
Description
I may found a bug with one-to-one GORM association, refer to : http://grails.org/doc/2.0.x/guide/GORM.html#gormAssociation -> one-to-one example B
This should work :
class BookController {
def index() {
def book = new Book()
book.name = "A new book"
book.author = new Author(name:"Grails")
book.save()
render(text:book.id)
}
}
class Book {
String name
Author author
static constraints = {
}
}
class Author {
String name
static belongsTo = [book:Book]
}
Error 500 : URI /g2/book/index Class org.h2.jdbc.JdbcSQLException Message NULL not allowed for column "AUTHOR_ID"; SQL statement: insert into book (id, version, author_id, name) values (null, ?, ?, ?) [90006-147]
Issue Links
| This issue is duplicated by: | ||||
| GRAILS-8590 | bidirectional one-to-one relation did not save child objects when constructor isn't used |
|
|
|
| GRAILS-8451 | Transitative persistence for Many-to-one associations not cascading saves |
|
|
|
This works if you set both sides of the association and in fact that is what is happening in the example in the documentation.