Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Wither
- @Data
- @AllArgsConstructor
- @NoArgsConstructor
- @EqualsAndHashCode
- @Entity
- @Table(name = "tbl_psf_transacciones", schema = "schecopa")
- @DynamicInsert
- public class Transaction extends AuditModel {
- @Id
- @Column(name = "transaccion_id")
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long transactionId;
- /** Some transaction fields **/
- @LazyCollection(LazyCollectionOption.EXTRA)
- @OneToMany
- @JoinColumn(name = "transaccion_id")
- private Set<Metadata> metadata = new HashSet<>();
- @LazyCollection(LazyCollectionOption.EXTRA)
- @OneToMany
- @JoinColumn(name = "transaccion_id")
- private Set<Movement> movements = new HashSet<>();
- @LazyCollection(LazyCollectionOption.EXTRA)
- @OneToMany
- @JoinColumn(name = "transaccion_id")
- private Set<Response> responses = new HashSet<>();
- @LazyCollection(LazyCollectionOption.EXTRA)
- @OneToMany
- @JoinColumn(name = "transaccion_id")
- private Set<Amount> amounts = new HashSet<>();
- @LazyCollection(LazyCollectionOption.EXTRA)
- @OneToMany
- @JoinColumn(name = "transaccion_id")
- private Set<Tracking> trackings = new HashSet<>();
- }
- public interface TransactionRepository extends JpaRepository<Transaction, Long> {
- @Query(value = "select distinct t from Transaction t " +
- "join t.movements as movement " +
- "on t.transactionId = movement.transaction.transactionId " +
- "and movement.customerDocumentType = coalesce(cast(:destinationDocumentType as string), movement.customerDocumentType) " +
- "and movement.customerDocumentNumber = coalesce(cast(:detinationDocumentNumber as string), movement.customerDocumentNumber) " +
- "and movement.movementType = 'DESTINO' " +
- "where t.paymentMethod = coalesce(cast(:paymentMethod as string), t.paymentMethod) " +
- "and t.date between :startDate and :endDate " +
- "and t.commerceId = coalesce(cast(:idCommerce as string), t.commerceId) " +
- "and t.status = coalesce(cast(:idStatus as string), t.status) ")
- Page<Transaction> findAllByQueryParams(@Param("paymentMethod") String paymentMethod, @Param("startDate") Date start_date,
- @Param("endDate") Date end_date, @Param("destinationDocumentType") String destinationDocumentType,
- @Param("detinationDocumentNumber") String destinationDocumentNumber, @Param("idCommerce") String idCommerce,
- @Param("idStatus") String idStatus, Pageable pageable);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement