Answer the question
In order to leave comments, you need to log in
Is it possible to work on JDBC and DATAJPA at the same time?
To work with the database, I use Spring DataJpa and, accordingly, JpaTransactionManager :
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"/>
I also want to work directly with the database via JDBC. However, JDBC needs another transaction manager - DataSourceTransactionManager :<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
Answer the question
In order to leave comments, you need to log in
Yes, it is possible, but it is very bad! JPA generally caches data and queries, while JDBC does not. As a result, it is possible to run into trouble, especially if you made an update via JDBC and immediately after that, a selection via JPA. You can get Schrödinger's cat....
And why, if JPA has createNativeQuery (damn, I still remember something...) - https://thorben-janssen.com/jpa-native-queries/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question