public class EntParent{
@OneToMany
List<Ent1> manyEnt1;
}
public class Ent1 {
Field1
Field2
@ManyToOne
EntParent dad;
getField1
setField1
getField2
setField2
getDad
setDad
}
public class Ent1ManagerEJB{
}
in this scenario who(Ent1 or Ent1ManagerEJB or EntParent) should have methods to perform following
1) manipulate fields in Ent1
2) fetch fields of Ent1 with some logic
3) Fetch some other Entity depending on some logic that works on values of fields in Ent1,if EntParent and mappings are absent
4) Fetch some other Entity depending on some logic that works on values of fields in Ent1,if Ent1 is in @OneToMany mapping with some other Entity eg EntParent contains Ent1 in array
also if possible point to some resource that teaches me about such patterns/problems..
Domain objects represent important concepts in the target domain and so must often be persistent. The Java Persistence API (JPA) turns out to be quite flexible for mapping rich domain objects to relational tables. The more complex the logic you need to realize, the more easily object-oriented persistence can be maintained and developed.
The real issue with complex logic realized with anemic structures are type distinctions in the service layer. Massive if-statements might be necessary to differentiate among entity types. Every introduction of a new subclass, or even a change in the existing business logic, requires you to find, enhance, and test these type checks.
Admam Bien
you can take advantage of concept "Domain-driven design" which Adam Bien talked about in his article:
http://www.javaworld.com/javaworld/jw-05-2009/jw-05-domain-driven-design.html?page=2?