Skip to content
Snippets Groups Projects

Album search

Merged Stian Fjæran Mogen requested to merge album_search into dev
2 files
+ 44
0
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -19,6 +19,8 @@ public class AlbumRepository extends AbstractRepository<Album, Long> {
* Mapping to @NamedQuery 'find all albums by users username' defined in {@link Album}
*/
public static final String ALBUM_FIND_BY_USERNAME = "Album.findAllByUsername";
public static final String ALBUM_FIND_BY_TAGS = "Album.findByTags";
public static final String ALBUM_FIND_BY_TITLE = "Album.findByTitle";
/**
* Constructor to inject {@link EntityManager} dependency and sets the class type to {@link Album}
@@ -42,4 +44,17 @@ public class AlbumRepository extends AbstractRepository<Album, Long> {
.getResultList();
}
public List<Album> findAllByTags(String tag){
return entityManager.createNamedQuery(ALBUM_FIND_BY_TAGS, Album.class)
.setParameter("name",tag)
.getResultList();
}
public List<Album> findAllByTitle(String title){
return entityManager.createNamedQuery(ALBUM_FIND_BY_TITLE, Album.class)
.setParameter("title", title)
.getResultList();
}
}
Loading