GORM is imho one of the best possibilities to define an ORM model, since it hides all technical aspects of the implementation and lets the developer describe the domain model in a clear an consistent way.
Therefore this clearness should still be around when using JCR as backend.
Take an Grails/GORM example:
class Author {The dynamical nature of Grails adds the necessary properties, you could also write it as
static hasMany = [ books : Book ]
String name
}
class Book {
static belongsTo = [author:Author]
String title
}
class Author {There are 2 aspects to this domain model
static hasMany = [ books : Book ]
String name
Set books
}
class Book {
static belongsTo = [author:Author]
Author author
String title
}
- object relations: an author has a set of books
- constraints: you have to make sure that a book really has an author (except when you define this property as nullable, which is also a contraint in this sense)
- the one-to-many relation author vs. books would typically be mapped by a hierarchical manner, e.g.
/authors
/stephen king
/books
/Misery
etc. - the constraints, on the other hand would mean to add a structure to the repository by, e.g., defining node types. I think, that's what David means. Might be nice to have (I personally don't mind structure), but is not mandatory
Keine Kommentare:
Kommentar veröffentlichen