Since you have defined your Spring transactions via @Transactional
, you are by default running inside of an auto-commit transaction. As per this other thread, you need to create a second session factory which runs in autocommit = false
to retrieve the file.
Additionally, the DAO for the retrieval should be annotated with @Qualifier
so that it knows which session factory to use. Example:
@Autowired
public MyDAOImpl(@Qualifier("someSessionFactory") SessionFactory sessionFactory) {
setSessionFactory(sessionFactory);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…