Skip to content

Instantly share code, notes, and snippets.

@sandipchitale
Created October 17, 2024 05:29
Show Gist options
  • Save sandipchitale/ebf68f4e62ec307fd9c3df958a435bbf to your computer and use it in GitHub Desktop.
Save sandipchitale/ebf68f4e62ec307fd9c3df958a435bbf to your computer and use it in GitHub Desktop.
Use ctid in spring data JPS repository #postgres #sringdatajpa
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import java.util.Optional;
public interface NamesToDiff1Repository extends CrudRepository<NamesToDiff1, Long> {
@Query(value = "SELECT ctid FROM names", nativeQuery = true)
Iterable<Object> findAllRowIds();
@Query(value = "SELECT * FROM names WHERE ctid = ?::tid", nativeQuery = true)
Optional<NamesToDiff1> findByCtId(String ctid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment