Interface DroidRepository

All Superinterfaces:
org.springframework.data.repository.CrudRepository<Droid,UUID>, org.springframework.data.repository.Repository<Droid,UUID>

public interface DroidRepository extends org.springframework.data.repository.CrudRepository<Droid,UUID>
Author:
etienne-sf
  • Method Details

    • findAll

      @Query(value="select d.id, d.name, d.primary_function from droid d", nativeQuery=true) List<Droid> findAll()
      Specified by:
      findAll in interface org.springframework.data.repository.CrudRepository<Droid,UUID>
    • findAppearsInById

      @Query(value=" select e.label from droid_appears_in dai, episode e where dai.episode_id=e.id and dai.droid_id = ?1", nativeQuery=true) List<String> findAppearsInById(UUID id)
    • findByAppearsIn

      @Query(value=" select d.id, d.name, d.primary_function from droid d, droid_appears_in dai, episode e where e.label = ?1 and dai.episode_id=e.id and dai.droid_id=d.id", nativeQuery=true) List<Droid> findByAppearsIn(String episode)
    • findFriends

      @Query(value=" select d.id, d.name, d.primary_function from droid d, character_friends f where f.character_id = ?1 and f.friend_id = d.id ", nativeQuery=true) List<Droid> findFriends(UUID id)
    • addFriend

      @Modifying @Query(value="insert into character_friends (character_id, friend_id) values (?1, ?2)", nativeQuery=true) void addFriend(UUID idCharacter, UUID idFriend)
    • findById

      @Query(value="select id, name, primary_function from droid where id = ?1", nativeQuery=true) Optional<Droid> findById(UUID id)
      As in this implementation, we have separate tables for the concrete classes of the Character interface, we use a nativeQuery. Another option is to use a CharacterImpl view.
      Specified by:
      findById in interface org.springframework.data.repository.CrudRepository<Droid,UUID>
    • batchLoader

      @Query(value="select id, name, primary_function from droid where id = ?1", nativeQuery=true) List<Droid> batchLoader(List<UUID> keys)