22
33import io .micronaut .data .annotation .Query ;
44import io .micronaut .data .annotation .Repository ;
5+ import io .micronaut .data .model .Pageable ;
56import io .micronaut .data .repository .PageableRepository ;
67import net .onelitefeather .vulpes .api .model .ItemEntity ;
78
@@ -25,33 +26,42 @@ public interface ItemRepository extends PageableRepository<ItemEntity, UUID> {
2526 * @param id the unique identifier of the item
2627 * @return a map of enchantment names and their levels associated with the item
2728 */
28- @ Query ("SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id" )
29- Map <String , Short > findEnchantmentsById (UUID id );
29+ @ Query (value = "SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id" ,
30+ countQuery = "SELECT count(e) FROM items i JOIN i.enchantments e WHERE i.id = :id"
31+ )
32+ Map <String , Short > findEnchantmentsById (UUID id , Pageable pageable );
3033
3134 /**
3235 * Retrieves the lore associated with an item by its ID.
3336 *
3437 * @param id the unique identifier of the item
3538 * @return a list of lore strings associated with the item
3639 */
37- @ Query ("SELECT l FROM items i JOIN i.enchantments l WHERE i.id = :id" )
38- List <String > findLoreById (UUID id );
40+ @ Query (value = "SELECT l FROM items i JOIN i.lore l WHERE i.id = :id" ,
41+ countQuery = "SELECT count(l) FROM items i JOIN i.lore l WHERE i.id = :id"
42+ )
43+ List <String > findLoreById (UUID id , Pageable pageable );
3944
4045 /**
4146 * Retrieves the flags associated with an item by its ID.
4247 *
4348 * @param id the unique identifier of the item
4449 * @return a list of flags associated with the item
4550 */
46- @ Query ("SELECT f FROM items i JOIN i.enchantments f WHERE i.id = :id" )
47- List <String > findFlagsById (UUID id );
51+ @ Query (value = "SELECT f FROM items i JOIN i.flags f WHERE i.id = :id" ,
52+ countQuery = "SELECT count(f) FROM items i JOIN i.flags f WHERE i.id = :id"
53+ )
54+ List <String > findFlagsById (UUID id , Pageable pageable );
4855
4956
5057 /**
5158 * Retrieves all items along with their associated enchantments, lore, and flags.
5259 *
5360 * @return a list of all ItemEntity objects with their enchantments, lore, and flags
5461 */
55- @ Query ("SELECT i FROM items i LEFT JOIN FETCH i.enchantments LEFT JOIN FETCH i.lore LEFT JOIN FETCH i.flags" )
56- List <ItemEntity > findAllWithFetches ();
62+ @ Query (
63+ value = "SELECT i FROM items i LEFT JOIN FETCH i.enchantments LEFT JOIN FETCH i.lore LEFT JOIN FETCH i.flags" ,
64+ countQuery = "SELECT count(i) FROM items i"
65+ )
66+ List <ItemEntity > findAllWithFetches (Pageable pageable );
5767}
0 commit comments