Announcement Announcement Module
No announcement yet.
Mixing hibernate & spring into single beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mixing hibernate & spring into single beans

    I dunno if i'm doing the correct thing, but I have objects that have both persistent data and dependency to other objects, where Hibernate manages the persistence of the data and spring manages the dependencies.
    The problem is, when hibernate creates an object it will simply call its constructor and initialize it, instead of letting spring somehow manage the dependencis before using it, So the objects returned by hibernate will have incorrect or null dependencies. I know some patterns to overcome this using factory methods or adapter objects, but :
    1 - Is this way of combinig Spring's Dependency Injection & Hibernate's Persistence correct ?
    2 - Is it good or bad to have such objects, containing both data & dependency ?
    3 - Is their anyway to tell hibernate to get its objects from spring's application context instead of creating it ?

    Thanx ..

  • #2
    Please take a look at this thread How Common to Spring Manage Beans Created By Hibernate?. It may answer some of your questions.
    Last edited by robyn; May 19th, 2006, 06:07 AM.