spring-data

Spring Data and MongoDB repository - how to create an update query?

时间秒杀一切 提交于 2020-06-27 11:30:16
问题 I have the following jpa repository: @Query("UPDATE PlayerAccount pa SET pa.password = ?3 WHERE pa.id = ?1 AND pa.password = ?2") @Modifying public int updatePasswordWithValidation(Long playerAccountId, String oldPasswordDB, String encodePassword); Now, i would like to implement a similar update

SpringFramework: @Transactional(readOnly = true) not working with h2

血红的双手。 提交于 2020-06-27 09:10:28
问题 I am doing transaction testing with the SpringFramework. I have the following classes. UserService.class @Transactional public interface UserService { void add(User user); @Transactional(readOnly = true) User get(String id); @Transactional(readOnly = true) List<User> getAll(); void deleteAll();

How should I register custom Hibernate 5 data type (BasicType) when Spring Data is used?

一世执手 提交于 2020-06-24 11:48:09
问题 I use Spring Data and decided that I want to create new custom data type that can be used in Hibernate entities. I checked the documentation and choose BasicType and implemented it according to this official user guide. I wanted to be able to register the type under its class name and be able to

Why does Spring get circular dependency issues on one machine and not another?

最后都变了- 提交于 2020-06-24 04:12:30
问题 I have a problem getting a Spring Data based application to run in my environment. I am running Debian, but my co-workers are either using Mac or Ubuntu. I have nothing special set up in my environment variables, and am using the exact same version of Java as others. I have seen this in the logs,

Spring Data Repository @Query - Update and return modified entity

浪子不回头ぞ 提交于 2020-06-21 04:05:13
问题 let's assume we have a Spring Data repository interface with a custom method... @Modifying @Transactional @Query("UPDATE MyEntity SET deletedAt = CURRENT_TIMESTAMP WHERE id = ?1") void markAsSoftDeleted(long id); This method simply sets the deletedAt field of the entity, ok. Is there any way to

Spring data JPA - Hibernate - TransientObjectException when updating an existing entity with transient nested children

十年热恋 提交于 2020-06-17 09:44:08
问题 Following my first question here, the question has changed so I'm creating a new one : org.hibernate.TransientObjectException persisting nested children with CascadeType.ALL I found that my problem was not saving a new entity but updating an existing one. Let's start from the beginning. I have a