Interface Inventory<T extends InventoryItem<?>>

All Known Subinterfaces:
MultiInventory<T>, UniqueInventory<T>

@NoRepositoryBean public interface Inventory<T extends InventoryItem<?>>
Base interface for InventoryItem implementations. Choose either UniqueInventory or MultiInventory for your application depending on whether you need to keep track of multiple locations (e.g. warehouses) in which InventoryItems 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 the UniqueInventoryItem by Product.ProductIdentifier. I.e. the Quantity contained in that UniqueInventoryItem is equivalent to the overall quantity in the system. This is the simpler model in general and should be preferred. Products held in UniqueInventoryItems are suspect to automatic inventory updates on order completion. See InventoryListeners.InventoryOrderEventListener for details.

If you absolutely need to model Products managed in multiple warehouses, use MultiInventoryItem alongside MultiInventory. MultiInventory.findByProductIdentifier(ProductIdentifier) rather returns an InventoryItems instance. The overall Quantity of Products in the system can then be obtained via InventoryItems.getTotalQuantity(). MultiInventoryItems are not suspect to auto-inventory updates upon order completion as it's not clear which of the InventoryItems is supposed to be deducted.

Since:
7.2
Author:
Oliver Drotbohm