How to use @Transactional with Spring Data?

What is your question actually about? The usage of the @Repository annotation or @Transactional. @Repository is not needed at all as the interface you declare will be backed by a proxy the Spring Data infrastructure creates and activates exception translation for anyway. So using this annotation on a Spring Data repository interface does not have … Read more

Delete Not Working with JpaRepository

Most probably such behaviour occurs when you have bidirectional relationship and you’re not synchronizing both sides WHILE having both parent and child persisted (attached to the current session). This is tricky and I’m gonna explain this with the following example. @Entity public class Parent { @Id @GeneratedValue(strategy = IDENTITY) @Column(name = “id”, unique = true, … Read more

Call another rest api from my server in Spring-Boot

This website has some nice examples for using spring’s RestTemplate. Here is a code example of how it can work to get a simple object: private static void getEmployees() { final String uri = “http://localhost:8080/springrestexample/employees.xml”; RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject(uri, String.class); System.out.println(result); }

Spring data JPA query with parameter properties

This link will help you: Spring Data JPA M1 with SpEL expressions supported. The similar example would be: @Query(“select u from User u where u.firstname = :#{#customer.firstname}”) List<User> findUsersByCustomersFirstname(@Param(“customer”) Customer customer); https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions

Missing CrudRepository#findOne method

Please see DATACMNS-944 which is associated to this commit which has the following renames ╔═════════════════════╦═══════════════════════╗ ║ Old name ║ New name ║ ╠═════════════════════╬═══════════════════════╣ ║ findOne(…) ║ findById(…) ║ ╠═════════════════════╬═══════════════════════╣ ║ save(Iterable) ║ saveAll(Iterable) ║ ╠═════════════════════╬═══════════════════════╣ ║ findAll(Iterable) ║ findAllById(…) ║ ╠═════════════════════╬═══════════════════════╣ ║ delete(ID) ║ deleteById(ID) ║ ╠═════════════════════╬═══════════════════════╣ ║ delete(Iterable) ║ deleteAll(Iterable) ║ ╠═════════════════════╬═══════════════════════╣ ║ exists() … Read more