Package NTNU.IDATT1002.repository
Class AlbumRepository
java.lang.Object
NTNU.IDATT1002.repository.AbstractRepository<T,ID>
NTNU.IDATT1002.repository.PagingAndSortingRepository<Album,java.lang.Long>
NTNU.IDATT1002.repository.AlbumRepository
- All Implemented Interfaces:
Repository<Album,java.lang.Long>
public class AlbumRepository extends PagingAndSortingRepository<Album,java.lang.Long>
Album Repository.
Implementation of
AbstractRepository
which supports regular Create, Read, Update and Delete operations.
Supports paginated and sorted content through PagingAndSortingRepository
.- Version:
- 1.0 19.03.20
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ALBUM_FIND_BY_TAGS
static java.lang.String
ALBUM_FIND_BY_TITLE
static java.lang.String
ALBUM_FIND_BY_USERNAME
Mapping to @NamedQuery 'find all albums by username, tags, and title' defined inAlbum
static java.lang.String
ALBUM_FIND_PREVIEW_IMAGE
Fields inherited from class NTNU.IDATT1002.repository.AbstractRepository
entityClass, entityManager, logger
-
Constructor Summary
Constructors Constructor Description AlbumRepository(javax.persistence.EntityManager entityManager)
Set the class type toAlbum
-
Method Summary
Modifier and Type Method Description java.util.List<Album>
findAllByTags(java.lang.String tag)
java.util.List<Album>
findAllByTitle(java.lang.String title)
Find all albums by given title.java.util.List<Album>
findAllByUsername(java.lang.String username)
Retrieves all albums of the user with the given username.java.util.Optional<Image>
findPreviewImage(java.lang.Long albumId)
Find a single preview image from album with given id.Methods inherited from class NTNU.IDATT1002.repository.AbstractRepository
delete, deleteById, findAll, findById, save, setEntityClass, update
-
Field Details
-
ALBUM_FIND_BY_USERNAME
public static final java.lang.String ALBUM_FIND_BY_USERNAMEMapping to @NamedQuery 'find all albums by username, tags, and title' defined inAlbum
- See Also:
- Constant Field Values
-
ALBUM_FIND_BY_TAGS
public static final java.lang.String ALBUM_FIND_BY_TAGS- See Also:
- Constant Field Values
-
ALBUM_FIND_BY_TITLE
public static final java.lang.String ALBUM_FIND_BY_TITLE- See Also:
- Constant Field Values
-
ALBUM_FIND_PREVIEW_IMAGE
public static final java.lang.String ALBUM_FIND_PREVIEW_IMAGE- See Also:
- Constant Field Values
-
-
Constructor Details
-
AlbumRepository
public AlbumRepository(javax.persistence.EntityManager entityManager)Set the class type toAlbum
-
-
Method Details
-
findAllByUsername
Retrieves all albums of the user with the given username.- Parameters:
username
- the username to query for- Returns:
- the list of the users albums.
-
findAllByTags
-
findAllByTitle
Find all albums by given title.- Parameters:
title
- the title to query for- Returns:
- a list of albums found
-
findPreviewImage
Find a single preview image from album with given id. Creates a new entity manager for each call to allow concurrent fetching within the maximum connection pool size.- Parameters:
albumId
- the id of the album- Returns:
- Optional of image if found
-