Devices Repository

@Repository
interface DevicesRepository : JpaRepository<T, ID>

The DevicesRepository interface is useful to manage the queries for the devices operations

Author

N7ghtm4r3 - Tecknobit

See also

JpaRepository

Functions

Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = "INSERT INTO " + USER_DEVICES_KEY + " (" + IDENTIFIER_KEY + "," + USER_IDENTIFIER_KEY + "," + DEVICE_IDENTIFIER_KEY + ") VALUES (" + ":" + SESSION_IDENTIFIER_KEY + "," + ":" + USER_IDENTIFIER_KEY + "," + ":" + DEVICE_IDENTIFIER_KEY + ")", nativeQuery = true )
abstract fun attachDeviceToUser(    @Param(value = "session_id") sessionId: String,     @Param(value = "user_id") userId: String,     @Param(value = "device_id") deviceId: String)
Query used to attach a device to a user
Link copied to clipboard
abstract fun <S : T?> count(example: Example<S>): Long
Link copied to clipboard
@Query(value = ""SELECT COUNT(*) FROM " + USER_DEVICES_KEY + _WHERE_ + DEVICE_IDENTIFIER_KEY + "=:" + DEVICE_IDENTIFIER_KEY", nativeQuery = true )
abstract fun countDeviceReferences(@Param(value = "device_id") deviceId: String): Long
Query used to count the total references of the device between sessions
Link copied to clipboard
@Query(value = ""SELECT DISTINCT COUNT(*) FROM " + USER_DEVICES_KEY + _WHERE_ + USER_IDENTIFIER_KEY + "=:" + USER_IDENTIFIER_KEY", nativeQuery = true )
abstract fun countDevices(@Param(value = "user_id") userId: String): Long
Query used to count the total devices owned by a user
Link copied to clipboard
abstract fun delete(entity: T)
Link copied to clipboard
abstract fun deleteAll(entities: Iterable<out T>)
Link copied to clipboard
abstract fun deleteAllById(ids: Iterable<out ID>)
Link copied to clipboard
abstract fun deleteAllByIdInBatch(ids: Iterable<ID>)
Link copied to clipboard
abstract fun deleteAllInBatch(entities: Iterable<T>)
Link copied to clipboard
abstract fun deleteById(id: ID)
Link copied to clipboard
open fun deleteInBatch(entities: Iterable<T>)
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""DELETE FROM " + USER_DEVICES_KEY + _WHERE_ + USER_IDENTIFIER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND " + DEVICE_IDENTIFIER_KEY + "=:" + DEVICE_IDENTIFIER_KEY", nativeQuery = true )
abstract fun disconnectDevice(@Param(value = "user_id") userId: String, @Param(value = ConstantsKt.DEVICE_IDENTIFIER_KEY) deviceId: String)
Query used to disconnect a device from the session
Link copied to clipboard
abstract fun <S : T?> exists(example: Example<S>): Boolean
Link copied to clipboard
abstract fun existsById(id: ID): Boolean
Link copied to clipboard
abstract fun <S : T?> findAll(example: Example<S>): List<S>
abstract fun findAll(): Iterable<T>
abstract fun findAll(): List<T>
abstract fun findAll(pageable: Pageable): Page<T>
abstract fun <S : T?> findAll(example: Example<S>): Iterable<S>
abstract fun <S : T?> findAll(example: Example<S>, pageable: Pageable): Page<S>
Link copied to clipboard
abstract fun findAllById(ids: Iterable<ID>): Iterable<T>
abstract fun findAllById(ids: Iterable<ID>): List<T>
Link copied to clipboard
abstract fun <S : T?, R> findBy(example: Example<S>, queryFunction: (FluentQuery.FetchableFluentQuery<S>) -> R): R
Link copied to clipboard
abstract fun findById(id: ID): Optional<T>
Link copied to clipboard
abstract fun <S : T?> findOne(example: Example<S>): Optional<S>
Link copied to clipboard
abstract fun flush()
Link copied to clipboard
abstract fun getById(id: ID): T
Link copied to clipboard
@Query(value = ""SELECT DISTINCT new com.tecknobit.glider.services.users.dtos.DeviceLastLogin(" + "d," + "ud." + "lastLogin" + ") FROM com.tecknobit.glider.services.users.entities.ConnectedDevice d" + " INNER JOIN com.tecknobit.glider.services.users.entities.DeviceUserSession ud" + " ON d." + IDENTIFIER_KEY + "=" + "ud.device." + IDENTIFIER_KEY + " WHERE ud.user." + IDENTIFIER_KEY + "=:" + USER_IDENTIFIER_KEY" )
abstract fun getDevices(@Param(value = "user_id") userId: String, pageable: Pageable): List<DeviceLastLogin>
Query used to retrieve all the devices owned by the user
Link copied to clipboard
abstract fun getOne(id: ID): T
Link copied to clipboard
abstract fun getReferenceById(id: ID): T
Link copied to clipboard
abstract fun <S : T?> save(entity: S): S
Link copied to clipboard
abstract fun <S : T?> saveAll(entities: Iterable<S>): Iterable<S>
abstract fun <S : T?> saveAll(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAllAndFlush(entities: Iterable<S>): List<S>
Link copied to clipboard
abstract fun <S : T?> saveAndFlush(entity: S): S
Link copied to clipboard
@Modifying(clearAutomatically = true )
@Query(value = ""UPDATE " + USER_DEVICES_KEY + " SET " + LAST_LOGIN_KEY + "=:" + LAST_LOGIN_KEY + _WHERE_ + USER_IDENTIFIER_KEY + "=:" + USER_IDENTIFIER_KEY + " AND " + DEVICE_IDENTIFIER_KEY + "=:" + DEVICE_IDENTIFIER_KEY", nativeQuery = true )
abstract fun updateLastLogin(    @Param(value = "user_id") userId: String,     @Param(value = "device_id") deviceId: String,     @Param(value = "last_login") lastLogin: Long)
Query used to update the last login by a device in the specified session