Interface Inventory<T extends InventoryItem<?>>
-
- All Known Subinterfaces:
MultiInventory<T>
,UniqueInventory<T>
@NoRepositoryBean public interface Inventory<T extends InventoryItem<?>>
Base interface forInventoryItem
implementations. Choose eitherUniqueInventory
orMultiInventory
for your application depending on whether you need to keep track of multiple locations (e.g. warehouses) in whichInventoryItem
s are supposed to be managed.UniqueInventoryItem
expects a one-to-one relationship to a product, which is equivalent to modeling a single warehouse. That's simple and allows to look up theUniqueInventoryItem
byProductIdentifier
. I.e. theQuantity
contained in thatUniqueInventoryItem
is equivalent to the overall quantity in the system. This is the simpler model in general and should be preferred.Product
s held inUniqueInventoryItem
s are suspect to automatic inventory updates on order completion. SeeInventoryOrderEventListener
for details.If you absolutely need to model
Product
s managed in multiple warehouses, useMultiInventoryItem
alongsideMultiInventory
.MultiInventory.findByProductIdentifier(ProductIdentifier)
rather returns anInventoryItems
instance. The overallQuantity
ofProduct
s in the system can then be obtained viaInventoryItems.getTotalQuantity()
.MultiInventoryItem
s are not suspect to auto-inventory updates upon order completion as it's not clear which of theInventoryItem
s is supposed to be deducted.- Since:
- 7.2
- Author:
- Oliver Drotbohm
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description org.springframework.data.util.Streamable<T>
findItemsOutOfStock()
Returns allUniqueInventoryItem
s that are out of stock (i.e. theQuantity
's amount is equal or less than zero).
-
-
-
Method Detail
-
findItemsOutOfStock
@Query("select i from #{#entityName} i where i.quantity.amount <= 0") org.springframework.data.util.Streamable<T> findItemsOutOfStock()
Returns allUniqueInventoryItem
s that are out of stock (i.e. theQuantity
's amount is equal or less than zero).- Returns:
- will never be null.
-
-