Instead of putting data access code in entity bean itself it might be better to put code in another class and calling it from Entity Bean due to following reasons.

  1. In case underlying data model or data access mechanism changes then it might be very impractical to change source code in entity bean.
  2. DAO is better option for writing such code and calls these classes directly into entity bean.