Fix lob errors
This commit is contained in:
parent
300f749144
commit
e777f29585
2 changed files with 5 additions and 1 deletions
|
@ -6,6 +6,8 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DeviceRepository acts as a superclass for the other repositories so to mirror in the database the
|
* DeviceRepository acts as a superclass for the other repositories so to mirror in the database the
|
||||||
* class inheritance present among the various devices.
|
* class inheritance present among the various devices.
|
||||||
|
@ -20,6 +22,7 @@ public interface DeviceRepository<T extends Device> extends CrudRepository<T, Lo
|
||||||
* @param username a User's username
|
* @param username a User's username
|
||||||
* @return an optional device, empty if none found
|
* @return an optional device, empty if none found
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@Query("SELECT d FROM Device d JOIN d.room r JOIN r.user u WHERE d.id = ?1 AND u.username = ?2")
|
@Query("SELECT d FROM Device d JOIN d.room r JOIN r.user u WHERE d.id = ?1 AND u.username = ?2")
|
||||||
Optional<T> findByIdAndUsername(Long id, String username);
|
Optional<T> findByIdAndUsername(Long id, String username);
|
||||||
|
|
||||||
|
@ -29,6 +32,7 @@ public interface DeviceRepository<T extends Device> extends CrudRepository<T, Lo
|
||||||
* @param username the User's username
|
* @param username the User's username
|
||||||
* @return all devices of that user
|
* @return all devices of that user
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@Query("SELECT d FROM Device d JOIN d.room r JOIN r.user u WHERE u.username = ?1")
|
@Query("SELECT d FROM Device d JOIN d.room r JOIN r.user u WHERE u.username = ?1")
|
||||||
List<T> findAllByUsername(String username);
|
List<T> findAllByUsername(String username);
|
||||||
|
|
||||||
|
@ -38,6 +42,7 @@ public interface DeviceRepository<T extends Device> extends CrudRepository<T, Lo
|
||||||
* @param deviceId the device id
|
* @param deviceId the device id
|
||||||
* @return a user object
|
* @return a user object
|
||||||
*/
|
*/
|
||||||
|
@Transactional
|
||||||
@Query("SELECT u FROM Device d JOIN d.room r JOIN r.user u WHERE d.id = ?1")
|
@Query("SELECT u FROM Device d JOIN d.room r JOIN r.user u WHERE d.id = ?1")
|
||||||
User findUser(Long deviceId);
|
User findUser(Long deviceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,6 @@ public class Room {
|
||||||
* https://www.baeldung.com/java-base64-image-string
|
* https://www.baeldung.com/java-base64-image-string
|
||||||
* https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
|
* https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
|
||||||
*/
|
*/
|
||||||
@Lob
|
|
||||||
@Column(name = "image", columnDefinition = "TEXT")
|
@Column(name = "image", columnDefinition = "TEXT")
|
||||||
private String image;
|
private String image;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue