2017-04-18 1 views
1

Ich habe ein Problem, ein Objekt über ein Datum erholt ich mit Federdaten arbeiten das Problem ist, dass sich das Objekt zurückkehrt null ist trotz dieses Objekt nicht null ist Danke für Ihre Antwort bitte herzlichObject Recovery über ein Datum mit Federdaten

@Repository 
public interface ProspectStatistiqueRepository extends JpaRepository<ProspectStatique, Long> { 
    @Query("select p from ProspectStatique p where p.date_consultation =:date_consultation") 
    public ProspectStatique getProspectCountByDate(@Param("date_consultation") Date date_consultation); 

} 

@Autowired 
ProspectStatistiqueRepository prospectStatistiqueRepository; 
@GetMapping("/products") 
public ProductStatique findProductNumberBydate(@RequestParam String date) throws CustomerException, ParseException { 
    DateFormat format = new SimpleDateFormat("MMMM d, yyyy 'at' hh:mm a", Locale.ENGLISH); 
    Date dateConvert = format.parse(date); 
    System.out.println("date param " + date); 
    System.out.println("dateConvert variable" + dateConvert); 
    ProductStatique pp = productStatiqueService.getProductCount(dateConvert); 
    return pp; 
} 
+0

Bitte hinzufügen was von den System.outs gedruckt wird? – StanislavL

Antwort

1

verwendet man JpaRepository so können Sie „Zwischen“, „nach“ und „Vor“ zu behandeln Frist:

@Repository 
public interface ProspectStatistiqueRepository extends JpaRepository<ProspectStatique, Long> { 

//1-Between 
    public List<ProspectStatique> findByDate_consultationBetween(Date date1,Date date2); 

//2-After 
    public List<ProspectStatique> findByDate_consultationAfter(Date date); 

//3-Befor 
    public List<ProspectStatique> findByDate_consultationBefore(Date date); 

} 

für weitere Informationen können Sie Frühjahr sehen tun c http://docs.spring.io/spring-data/jpa/docs/1.3.4.RELEASE/reference/html/jpa.repositories.html