Merge branch '36-problems-when-executing-queries-on-rooms-due-to-lob-array' into 'dev'
Resolve "Problems when executing queries on rooms due to LOB array" Closes #36 See merge request sa4-2020/the-sanmarinoes/backend!47
This commit is contained in:
commit
3205dcf617
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.query.Param;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* DeviceRepository acts as a superclass for the other repositories so to mirror in the database the
|
||||
* 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
|
||||
* @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")
|
||||
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
|
||||
* @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")
|
||||
List<T> findAllByUsername(String username);
|
||||
|
||||
|
@ -38,6 +42,7 @@ public interface DeviceRepository<T extends Device> extends CrudRepository<T, Lo
|
|||
* @param deviceId the device id
|
||||
* @return a user object
|
||||
*/
|
||||
@Transactional
|
||||
@Query("SELECT u FROM Device d JOIN d.room r JOIN r.user u WHERE d.id = ?1")
|
||||
User findUser(Long deviceId);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,6 @@ public class Room {
|
|||
* https://www.baeldung.com/java-base64-image-string
|
||||
* https://docs.oracle.com/javase/8/docs/api/java/util/Base64.html
|
||||
*/
|
||||
@Lob
|
||||
@Column(name = "image", columnDefinition = "TEXT")
|
||||
private String image;
|
||||
|
||||
|
|
Loading…
Reference in a new issue