Nonverbis

Untitled

Nov 23rd, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. PersonRepo.java
  2.  
  3. @Query(value="select person.id, person.email, person.first_name, person.last_name, person.phone from orders join customers on orders.customer_id = customers.id join person on person.id=customers.person_id join order_item on order_id = orders.id where created >= :from and created <= :through and order_item.product_id= :productId", nativeQuery = true)
  4. Iterable<Person> findPeopleWhoBoughtProductWithinPeriod(@Param("productId") int productId,
  5. @Param("from") String from,
  6. @Param("through") String through);
  7.  
  8.  
  9.  
  10. GeneralService.java
  11.  
  12. Iterable<Person> peopleInFeb = personRepo.findPeopleWhoBoughtProductWithinPeriod(2,
  13. "2019-02-01",
  14. "2019-02-28");
  15.  
  16.  
  17. Traceback
  18.  
  19. Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone >= character varying
  20. Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
  21.  
  22.  
  23. PostgreSQL
  24. customer_order=# select person.id, person.email, person.first_name, person.last_name, person.phone from orders join customers on orders.customer_id = customers.id join person on person.id=customers.person_id join order_item on order_id = orders.id where created >= '2019-02-01' and created <= '2019-02-28' and order_item.product_id=2;
  25. id | email | first_name | last_name | phone
  26. ----+----------------+------------+-----------+-------------
  27. 1 | [email protected] | Michael | Petrov | 79898858635
  28. (1 row)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment