Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.60 KB | None | 0 0
  1. @Wither
  2. @Data
  3. @AllArgsConstructor
  4. @NoArgsConstructor
  5. @EqualsAndHashCode
  6. @Entity
  7. @Table(name = "tbl_psf_transacciones", schema = "schecopa")
  8. @DynamicInsert
  9. public class Transaction extends AuditModel {
  10.  
  11. @Id
  12. @Column(name = "transaccion_id")
  13. @GeneratedValue(strategy = GenerationType.IDENTITY)
  14. private Long transactionId;
  15.  
  16. /** Some transaction fields **/
  17.  
  18. @LazyCollection(LazyCollectionOption.EXTRA)
  19. @OneToMany
  20. @JoinColumn(name = "transaccion_id")
  21. private Set<Metadata> metadata = new HashSet<>();
  22.  
  23. @LazyCollection(LazyCollectionOption.EXTRA)
  24. @OneToMany
  25. @JoinColumn(name = "transaccion_id")
  26. private Set<Movement> movements = new HashSet<>();
  27.  
  28. @LazyCollection(LazyCollectionOption.EXTRA)
  29. @OneToMany
  30. @JoinColumn(name = "transaccion_id")
  31. private Set<Response> responses = new HashSet<>();
  32.  
  33. @LazyCollection(LazyCollectionOption.EXTRA)
  34. @OneToMany
  35. @JoinColumn(name = "transaccion_id")
  36. private Set<Amount> amounts = new HashSet<>();
  37.  
  38. @LazyCollection(LazyCollectionOption.EXTRA)
  39. @OneToMany
  40. @JoinColumn(name = "transaccion_id")
  41. private Set<Tracking> trackings = new HashSet<>();
  42. }
  43.  
  44. public interface TransactionRepository extends JpaRepository<Transaction, Long> {
  45. @Query(value = "select distinct t from Transaction t " +
  46. "join t.movements as movement " +
  47. "on t.transactionId = movement.transaction.transactionId " +
  48. "and movement.customerDocumentType = coalesce(cast(:destinationDocumentType as string), movement.customerDocumentType) " +
  49. "and movement.customerDocumentNumber = coalesce(cast(:detinationDocumentNumber as string), movement.customerDocumentNumber) " +
  50. "and movement.movementType = 'DESTINO' " +
  51. "where t.paymentMethod = coalesce(cast(:paymentMethod as string), t.paymentMethod) " +
  52. "and t.date between :startDate and :endDate " +
  53. "and t.commerceId = coalesce(cast(:idCommerce as string), t.commerceId) " +
  54. "and t.status = coalesce(cast(:idStatus as string), t.status) ")
  55. Page<Transaction> findAllByQueryParams(@Param("paymentMethod") String paymentMethod, @Param("startDate") Date start_date,
  56. @Param("endDate") Date end_date, @Param("destinationDocumentType") String destinationDocumentType,
  57. @Param("detinationDocumentNumber") String destinationDocumentNumber, @Param("idCommerce") String idCommerce,
  58. @Param("idStatus") String idStatus, Pageable pageable);
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement