package org.xmx0632.deliciousfruit.repository;
import java.util.Date;
import java.util.List;
import javax.persistence.QueryHint;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.xmx0632.deliciousfruit.entity.FruitPromotion;
public interface FruitPromotionDao extends
PagingAndSortingRepository<FruitPromotion, Long>,
JpaSpecificationExecutor<FruitPromotion> {
@Query("from FruitPromotion u where u.avaliable = 1 and u.picStatus = 1 and u.startTime <= ?1 and u.endTime >= ?1 and u.promotionType = ?2 ")
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
List<FruitPromotion> getAvailablePromotionBy(Date currentTime, int type);
@Query("from FruitPromotion u where u.avaliable = 1 and u.picStatus = 1 and u.startTime <= ?1 and u.endTime >= ?1 and u.promotionType = ?2 and u.fruitSubPromotion.product.id = ?3")
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") })
List<FruitPromotion> getAvailablePromotionBy(Date currentTime, int type,
Long productId);
}