Spring application doesn't appear to be persisting data

后端 未结 6 2091
甜味超标
甜味超标 2021-01-20 13:07

I\'m trying to write something into my database but it\'s not working despite it reporting \"Successfully completed request\". After the success everything seems to work fin

6条回答
  •  自闭症患者
    2021-01-20 13:57

    Looking at your applicationContext.xml again, I noticed you're not assigning an entityManager with your transactionManager declaration. I'm not sure if Spring will implicitly set it, but if it doesn't it would explain why your persists are not working.

    For example, change:

    
    
    to
    
    
      
    
    

    UPDATE

    I've only configured Spring+JPA with Container-managed Entity (looks like your intention as well) - never really Application-managed. From what I know, in Container-managed with Spring, you don't really need to configure a Persistent Unit. I'm not 100% sure if this will help but try changing how your entityManagerFactory is declared in applicationContext.xml.

    
    
       
    
          
    
       
          
       
    
       
          
             org.hibernate.dialect.MySQL5Dialect
             true
             ... //additional props
           
       
    
    

提交回复
热议问题