In Rails it is possible to declare a transitive relation as follows:
class Author < ActiveRecord::Base
has_many :authorships
has_many :books, :through => :authorships
end
Is it possible to do something similar in Hibernate? When I call author.getBooks() I want Hibernate to know to join authors with authorships with books.
I don’t believe there is anything in Hibernate’s mappings that can accomplish this, but you could simply add a
getBooks()method to yourAuthorclass that calls the correct method on theauthorshipsproperty:I’m not sure why the ORM would need to know about a transitive relationship between A and C between B, if you can just set that up in the class on it’s own.