Devices
Repository
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
)
Query used to attach a device to a user
Link copied to clipboard
@Query(value = ""SELECT COUNT(*) FROM " + USER_DEVICES_KEY +
_WHERE_ + DEVICE_IDENTIFIER_KEY + "=:" + DEVICE_IDENTIFIER_KEY",
nativeQuery = true
)
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
)
Query used to count the total devices owned
by a user
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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
)
Query used to disconnect a device from the
session
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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"
)
Query used to retrieve all the devices owned
by the user
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
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
)
Query used to update the last login by a
device in the specified session