Hello,
I am currently working on a Spring Roo/JPA application and I recently switched to a domain model based upon JPA inheritance. To sum up my domain model, I have an abstract Member entity that is subclassed by two entities: Male and Female.
In all of my Spring MVC controllers, I would like to avoid always injecting two service dependencies (one that would deal with Male entities and the other with Female entities). I'd rather have one MemberService service (together with a corresponding MemberRepository) that would return either a Male instance or a Female instance.
Is the above possible using Spring Roo annotations such as this one:or that one?Code:@RooService(domainTypes = { Member.class })For instance, will this (from MemberRepository)Code:@RooJpaRepository(domainType = Member.class)return an object that I can cast to either the Female or Male type?Code:Member findByEmail(String email);
More generally, what are the best practices to deal with entity inheritance at the level of Spring controllers and Spring services?
Thanks in advance,
J.


Reply With Quote
