[JAVA-2306] Fixes after Loredana's review
* Brought back UserRepositoryCustomImpl.java * Added link to https://www.baeldung.com/spring-data-jpa-query in spring-data-jpa-query-2 README * Migrated code for https://www.baeldung.com/spring-data-jpa-query-by-date * Migrated https://www.baeldung.com/spring-vs-jta-transactional to spring-persistence-simple
This commit is contained in:
-12
@@ -1,12 +0,0 @@
|
||||
package com.baeldung.spring.transactional;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
class TransactionalCompareApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TransactionalCompareApplication.class, args);
|
||||
}
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
package com.baeldung.spring.transactional.entity;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class Car {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||
private Long id;
|
||||
|
||||
private String make;
|
||||
|
||||
private String model;
|
||||
|
||||
public Car() {
|
||||
}
|
||||
|
||||
public Car(Long id, String make, String model) {
|
||||
this.id = id;
|
||||
this.make = make;
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getMake() {
|
||||
return make;
|
||||
}
|
||||
|
||||
public void setMake(String make) {
|
||||
this.make = make;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(String model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Car{" +
|
||||
"id=" + id +
|
||||
", make='" + make + '\'' +
|
||||
", model='" + model + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.baeldung.spring.transactional.repository;
|
||||
|
||||
import com.baeldung.spring.transactional.entity.Car;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CarRepository extends JpaRepository<Car, Long> {
|
||||
}
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.baeldung.spring.transactional.service;
|
||||
|
||||
import com.baeldung.spring.transactional.entity.Car;
|
||||
import com.baeldung.spring.transactional.repository.CarRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityExistsException;
|
||||
|
||||
@Service
|
||||
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.SUPPORTS, readOnly = false, timeout = 30)
|
||||
public class CarService {
|
||||
|
||||
@Autowired
|
||||
private CarRepository carRepository;
|
||||
|
||||
@Transactional(rollbackFor = IllegalArgumentException.class, noRollbackFor = EntityExistsException.class,
|
||||
rollbackForClassName = "IllegalArgumentException", noRollbackForClassName = "EntityExistsException")
|
||||
public Car save(Car car) {
|
||||
return carRepository.save(car);
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.baeldung.spring.transactional.service;
|
||||
|
||||
import com.baeldung.spring.transactional.entity.Car;
|
||||
import com.baeldung.spring.transactional.repository.CarRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.persistence.EntityExistsException;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@Service
|
||||
@Transactional(Transactional.TxType.SUPPORTS)
|
||||
public class RentalService {
|
||||
|
||||
@Autowired
|
||||
private CarRepository carRepository;
|
||||
|
||||
@Transactional(rollbackOn = IllegalArgumentException.class, dontRollbackOn = EntityExistsException.class)
|
||||
public Car rent(Car car) {
|
||||
return carRepository.save(car);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user