0

I'm working with Java and the Spring Framework, and with hibernate. I wrote an Interface to get some inventory stuff by Querys, one for a Location, where the Inventory is and one for a ProductType:

    public interface ProductInventory extends Inventory<InventoryItem> {

      @Query("select i from InventoryItem i, ProductItem c where i.product = c and c.type = ?1")
      List<InventoryItem> findByProductType(ProductItem.ProductItem type);

      @Query("select i from InventoryItem i, ProductItem c where i.product = c and c.locationid = ?1")
      List<InventoryItem> findByProductLocation(long locationid);
    } 

this is working perfect, but now i want to write an Query which selects the ProductType and the location:

     @Query("select i from InventoryItem i, ProductItem c where i.product = c and c.type = ?1 and c.locationid = ?1")
     List<InventoryItem> findByProductStandortAndType(ProductItem.ProductItemType type, long locationid);

but this isn't working. Maybe anyone can help me? Thanks a lot

1 Answer 1

2

So why are you not using the second parameter in the query? You have "?1" for the first parameter twice.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.