Spring boot doesn’t load data to initialize database using data.sql
Try adding this line in application.properties: spring.sql.init.mode=always Or for Spring Boot before 2.5: spring.datasource.initialization-mode=always
Try adding this line in application.properties: spring.sql.init.mode=always Or for Spring Boot before 2.5: spring.datasource.initialization-mode=always
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
(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
I was to add exclusion annotation to my main annotated class, i.e. instead of @SpringBootApplication I should have @SpringBootApplication @EnableAutoConfiguration(exclude={MongoAutoConfiguration.class})
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
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
UPDATE: The answer below is valid if you need to stay on a Hibernate version < 5.0. Hibernate 5.0 supports persisting JSR-310 date/time types out of the box. I.e. if you are on Hibernate 5.0 or newer, Adam’s answer is the way to go. Everyone else, read on. The root cause for this at none … Read more
Page<Video> videos = videoRepository.findAllVideos(new PageRequest(1, 50)); List<Video> videosList = videos.getContent(); You can use the above code to get the list of videos from page
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
Page extends Slice and knows the total number of elements and pages available by triggering a count query. From the Spring Data JPA documentation: A Page knows about the total number of elements and pages available. It does so by the infrastructure triggering a count query to calculate the overall number. As this might be … Read more