Spring JPA repository transactionality

You are right. Only CRUD methods (CrudRepository methods) are by default marked as transactional. If you are using custom query methods you should explicitly mark it with @Transactional annotation. @Repository public interface UserRegistrationRepository extends JpaRepository<UserRegistration, Long> { UserRegistration findByEmail(String email); @Transactional void deleteByEmail(String email); } You should also be aware about consequences of marking repository … Read more

Using @EmbeddedId with JpaRepository

(by Yosi Lev) This can be done as the following: Suppose your main entity is: @Entity @Table(name=”JRULES_FLOW”) public class JrulesFlow implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private JrulesFlowPK id; @Column(name=”NEXT_SEQ”) private int nextSeq; @Column(name=”REF_ID”) private String refId; @Column(name=”TASK_TYPE”) private String taskType; @Column(name=”VALUE_TO_FIND”) private String valueToFind; } And your PK class … Read more

How to make Spring server to start even if database is down?

You can set: spring.sql.init.continue-on-error=true in your application.properties. According to the Spring Boot 2.5.5 user guide: By default, Spring Boot enables the fail-fast feature of its script-based database initializer. This means that, if the scripts cause exceptions, the application fails to start. You can tune that behavior by setting spring.sql.init.continue-on-error. P.S.: Before Spring Boot 2.5, the … Read more

What’s the difference between Spring Data MongoDB and Hibernate OGM for MongoDB?

Disclaimer: I am the lead of the Spring Data project, so I’ll mostly cover the Spring Data side of things here: I think the core distinction between the two projects is that the Hibernate OGM team chose to center their efforts around the JPA while the Spring Data team explicitly did not. The reasons are … Read more

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

I’ve the same issue on Ubuntu 16.04. I found that the problem with @ComponentScan(basePackages = “com.my.app”) The code is running at least 5 different machine (windows, ubuntu 15.04 and ubuntu 16.04 desktop) but doesn’t start our CI server (ubuntu 16.04 server). After I changed @ComponentScan(basePackages = “com.my.app”) to @ComponentScan(basePackages = {“com.my.app.service”, “com.my.app.config”, “com.my.app”}) the code … Read more