Skip to content

Commit 0b6f809

Browse files
committed
feat(ItemRepository): add pagination support for item queries with enchantments, lore, and flags
1 parent 110e649 commit 0b6f809

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/main/java/net/onelitefeather/vulpes/api/repository/ItemRepository.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,42 @@ public interface ItemRepository extends PageableRepository<ItemEntity, UUID> {
2525
* @param id the unique identifier of the item
2626
* @return a map of enchantment names and their levels associated with the item
2727
*/
28-
@Query("SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id")
29-
Map<String, Short> findEnchantmentsById(UUID id);
28+
@Query(value = "SELECT e FROM items i JOIN i.enchantments e WHERE i.id = :id",
29+
countQuery = "SELECT count(e) FROM items i JOIN i.enchantments e WHERE i.id = :id"
30+
)
31+
Map<String, Short> findEnchantmentsById(UUID id, Pageable pageable);
3032

3133
/**
3234
* Retrieves the lore associated with an item by its ID.
3335
*
3436
* @param id the unique identifier of the item
3537
* @return a list of lore strings associated with the item
3638
*/
37-
@Query("SELECT l FROM items i JOIN i.lore l WHERE i.id = :id")
38-
List<String> findLoreById(UUID id);
39+
@Query(value = "SELECT l FROM items i JOIN i.lore l WHERE i.id = :id",
40+
countQuery = "SELECT count(l) FROM items i JOIN i.lore l WHERE i.id = :id"
41+
)
42+
List<String> findLoreById(UUID id, Pageable pageable);
3943

4044
/**
4145
* Retrieves the flags associated with an item by its ID.
4246
*
4347
* @param id the unique identifier of the item
4448
* @return a list of flags associated with the item
4549
*/
46-
@Query("SELECT f FROM items i JOIN i.flags f WHERE i.id = :id")
47-
List<String> findFlagsById(UUID id);
50+
@Query(value = "SELECT f FROM items i JOIN i.flags f WHERE i.id = :id",
51+
countQuery = "SELECT count(f) FROM items i JOIN i.flags f WHERE i.id = :id"
52+
)
53+
List<String> findFlagsById(UUID id, Pageable pageable);
4854

4955

5056
/**
5157
* Retrieves all items along with their associated enchantments, lore, and flags.
5258
*
5359
* @return a list of all ItemEntity objects with their enchantments, lore, and flags
5460
*/
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();
61+
@Query(
62+
value = "SELECT i FROM items i LEFT JOIN FETCH i.enchantments LEFT JOIN FETCH i.lore LEFT JOIN FETCH i.flags",
63+
countQuery = "SELECT count(i) FROM items i"
64+
)
65+
List<ItemEntity> findAllWithFetches(Pageable pageable);
5766
}

0 commit comments

Comments
 (0)