-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnectionPinRepository.java
More file actions
27 lines (22 loc) · 1.06 KB
/
Copy pathConnectionPinRepository.java
File metadata and controls
27 lines (22 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package com.dbaagent.repository;
import com.dbaagent.model.ConnectionPin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
public interface ConnectionPinRepository extends JpaRepository<ConnectionPin, Long> {
/**
* Case-insensitive, matching how {@code ConnectionAccessGrantRepository} resolves
* usernames — a login that differs only in casing must not end up with a second pin
* the unique constraint cannot see.
*/
@Query("select p from ConnectionPin p where lower(p.username) = lower(?1)")
Optional<ConnectionPin> findByUsernameIgnoreCase(String username);
/**
* Derived deletes need their own transaction. Annotating a self-invoked caller does
* nothing — Spring proxies are bypassed by {@code this::} — which is the same trap
* {@code McpTokenRepository.deleteByUserId} documents.
*/
@Transactional
void deleteByConnectionId(String connectionId);
}