Spring JPA and persistence.xml

后端 未结 5 1793
自闭症患者
自闭症患者 2020-12-04 20:08

I\'m trying to set up a Spring JPA Hibernate simple example WAR for deployment to Glassfish. I see some examples use a persistence.xml file, and other examples do not. Some

5条回答
  •  -上瘾入骨i
    2020-12-04 20:32

    I'm confused. You're injecting a PU into the service layer and not the persistence layer? I don't get that.

    I inject the persistence layer into the service layer. The service layer contains business logic and demarcates transaction boundaries. It can include more than one DAO in a transaction.

    I don't get the magic in your save() method either. How is the data saved?

    In production I configure spring like this:

    
    

    along with the reference in web.xml

    For unit testing I do this:

    
    
    

提交回复
热议问题