Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. import org.springframework.data.jpa.repository.JpaRepository;
  2.  
  3. public interface FacilityRepository extends JpaRepository<Facility, Long> {
  4. }
  5.  
  6.  
  7. public interface FacilityService {
  8. public Facility create(Facility facility);
  9. }
  10.  
  11. @Service
  12. public class FacilityServiceImpl implements FacilityService {
  13.  
  14. @Resource
  15. private FacilityRepository countryRepository;
  16.  
  17. @Transactional
  18. public Facility create(Facility facility) {
  19. Facility created = facility;
  20. return facilityRepository.save(created);
  21. }
  22. }
  23.  
  24. interface ProductRepository<T extends Product> extends CrudRepository<T, Long> {
  25.  
  26. @Query("select p from #{#entityName} p where ?1 member of p.categories")
  27. Iterable<T> findByCategory(String category);
  28.  
  29. Iterable<T> findByName(String name);
  30. }
  31.  
  32. class MyClient {
  33.  
  34. @Autowired
  35. public MyClient(ProductRepository<Car> carRepository,
  36. ProductRepository<Wine> wineRepository) { … }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement