Best Way to Inject Hibernate Session by Spring 3

前端 未结 4 938
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 12:01

I am not sure whats the best way to inject Hibernate\'s session instance to DAO classes using Spring3. I am not using Spring\'s Hibernate Template support for this so here i

4条回答
  •  天命终不由人
    2020-12-02 12:02

    The advisable way of using Hibernate is through JPA (hibernate-entitymanager):

    @PersistenceContext
    private EntityManager entityManager;
    

    and in the applicationContext.xml:

    
        
         
        
            
                
            
        
    
    
    
    
    
        
    
    

    And you'll need a META-INF/persistence.xml

提交回复
热议问题