- Timestamp:
- 01/24/22 21:08:32 (3 years ago)
- Branches:
- master
- Children:
- 76712b2
- Parents:
- bdd6491
- Location:
- trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java
rbdd6491 rb738035 109 109 List<Location> getVillages(); 110 110 111 @Query(value = "SELECT * FROM locations AS l WHERE l.id_city = :cityId", nativeQuery = true) 112 List<Location> getLocationsForCity(@Param("cityId") Long cityId); 111 113 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaPlannerRepository.java
rbdd6491 rb738035 16 16 List<Planner> getPlannersByUser(@Param("username") String username ); 17 17 18 @Query(value = "delete from planners_contain WHERE planners_contain.id_location = :locationId", nativeQuery = true) 19 void deleteLocationFromPlanner(@Param("locationId") Long locationId); 18 @Query(value = "DELETE planners_contain " + 19 "FROM planners_contain " + 20 "JOIN planners ON planners_contain.id_planner = planners.id_planner " + 21 "JOIN locations ON planners_contain.id_location = locations.id_location " + 22 "WHERE planners_contain.id_planner = :plannerId AND planners_contain.id_location = :locationId", nativeQuery = true) 23 void deleteLocationFromPlanner(@Param("plannerId") Long plannerId, @Param("locationId") Long locationId); 20 24 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaUserRepository.java
rbdd6491 rb738035 2 2 3 3 import finki.diplomska.tripplanner.models.User; 4 import org.springframework.data.jpa.repository.Query; 4 5 import org.springframework.data.repository.CrudRepository; 6 import org.springframework.data.repository.query.Param; 5 7 import org.springframework.stereotype.Repository; 8 9 import java.util.List; 10 import java.util.Optional; 6 11 7 12 @Repository … … 9 14 User findByUsername(String username); 10 15 User getById(Long id); 16 17 @Query(value = "SELECT u.username FROM users AS u", nativeQuery = true) 18 List<String> getAllUsernames(); 19 20 @Query(value = "SELECT u.password FROM users AS u WHERE u.username LIKE :username ", nativeQuery = true) 21 Optional<String> getPassword(@Param("username") String username); 22 11 23 }
Note:
See TracChangeset
for help on using the changeset viewer.