ReactiveCrudRepository to use Hibernate in spring

Is it possible to use Hibernate and Mysql with ReactiveCrudRepository instead of CrudRepository? TL;DR: Not with Hibernate and MySQL, but with R2DBC and Postgres, Microsoft SQL Server or H2. Take a look at Spring Data R2DBC. Long Version Why not JPA? With Hibernate/JPA included this won’t happen in the foreseeable future. JPA is based on … Read more

How to manually start a transaction on a shared EntityManager in Spring?

You should use TransactionTemplate object to manage transaction imperatively: transactionTemplate.execute( status -> em.createNativeQuery(“TRUNCATE TABLE MyTable”).executeUpdate()); To create TransactionTemplate just use injected PlatformTransactionManager: transactionTemplate = new TransactionTemplate(platformTransactionManager); And if you want to use new transaction just invoke transactionTemplate.setPropagationBehavior( TransactionDefinition.PROPAGATION_REQUIRES_NEW);

How do you handle with bulk deleting by an array of IDs in Spring Data JPA?

Just add the following to your user repository interface void deleteByIdIn(List<Integer> ids); Spring will automatically generate the appropriate query via method name derivation. https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#jpa.query-methods EDIT: A litte more detail on this Using Springs Repository interfaces like CrudRepository, JpaRespository brings the basic set of database operations, like create, read, update, delete, paging, sorting and so on. … Read more

tech