Configure spring datasource for hibernate and @Transactional

前端 未结 2 2000
长发绾君心
长发绾君心 2021-01-14 05:22

At this moment I\'m using DriverManagerDataSource with @Transactional annotation to manage transactions. But all transactions are very very slow, probably because data sourc

2条回答
  •  难免孤独
    2021-01-14 05:59

    I am using in my application combination of two approaches. the first one is c3p0 connection pooling, its almost the same solution as chkal sugested. The second approach is to use Spring lazyConnectionDataSourceProxy, which creates lazy loading proxy that loads connection only if you hit the database. This is very useful, when you have second level cache and you are only reading cached data and queries - database wont be hit, and you don't need to acquire connection (which is pretty expensive).

    
        
        
        
        
        
        
        
        
        
        
        
    
    
    
    
        
    
    

提交回复
热议问题