Results 1 to 2 of 2

Thread: Mixing hibernate & spring into single beans

  1. #1
    Join Date
    Nov 2004
    Posts
    6

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

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

    Spring Modules Team
    http://irbouh.blogspot.com/

Similar Threads

  1. Replies: 57
    Last Post: Nov 15th, 2006, 11:07 AM
  2. Spring container fails with no exception
    By naor in forum Container
    Replies: 9
    Last Post: Oct 1st, 2005, 03:39 PM
  3. Replies: 0
    Last Post: Aug 25th, 2005, 05:11 AM
  4. Spring + Hibernate ORA-00936: missing expression
    By Hugh_la_Main in forum Data
    Replies: 1
    Last Post: Jun 28th, 2005, 08:48 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •