自定义存储库Spring Boot

时间:2017-10-23 12:24:26

标签: java spring spring-boot spring-data spring-data-jpa

我有正常的接口DAO,我想创建一些自定义方法。但后来我得到了PropertyReferenceException异常。这是我的课程:

LeadDao

public interface LeadDao extends JpaRepository<LeadEntity, Integer>, LeadDaoCustom {

}

LeadDaoCustom

public interface LeadDaoCustom {

    public Map<LocalDateTime, Integer> getLeadNumberInDateRange();

}

LeadDaoImpl

@Repository
public class LeadDaoImpl implements LeadDaoCustom {

@Autowired
LeadDao leadDao;

@PersistenceContext
private EntityManager entityManager;

/* (non-Javadoc)
 * @see com.quantox.leadex.core.persistance.dao.LeadDao#getLeadNumberByDayInDateRange()
 */
@SuppressWarnings("unchecked")
@Override
public Map<LocalDateTime, Integer> getLeadNumberInDateRange() {
    Query q1 = entityManager.createNativeQuery("SELECT addeddate, \r\n" + 
            "                      Count(DISTINCT campaignid, email) AS count \r\n" + 
            "               FROM   leads \r\n" + 
            "               GROUP  BY addeddate"); 
    org.hibernate.Query hibernateQuery =((org.hibernate.jpa.HibernateQuery)q1) .getHibernateQuery(); 
    return (Map<LocalDateTime, Integer>) hibernateQuery.setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE).uniqueResult();
}

}

在我的服务类中,我使用的是:

@Autowired
    private LeadDao leadDao;

但是当我开始申请时,我得到了这个错误:

Caused by: org.springframework.data.mapping.PropertyReferenceException: No property getLeadNumberInDateRange found for type LeadEntity!

0 个答案:

没有答案