按一对多关系子数据过滤

时间:2017-11-14 04:58:24

标签: hibernate spring-data-jpa hibernate-mapping hibernate-criteria

我想通过leadtransactions数据(日期)

进行过滤

这里我使用了leadtransation table中的交易详情日期。我想在我的leadtransation中按特定日期过滤。请帮我处理工作样本或将用DAO方法编写的特定代码。

@Entity
@Table(name = "lead_master")
public class Lead {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "lead_id", nullable = false, unique = true)
private int lead_id;

@Column(name = "first_name", nullable = false)
private String first_name;

@Column(name = "last_name")
private String last_name;

@Column(name = "company_name")
private String company_name;

@Column(name = "website")
private String website;

@Column(name = "email")
private String email;

@Column(name = "phone_number")
private String phone_number;

@Column(name = "job_type", nullable = false)
private String job_type;

@Column(name = "date", nullable = false)
private Date date;

@Column(name = "time_stamp", nullable = false)
private Date time_stamp;

@Column(name = "status", nullable = false)
private int status;

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinTable(name = "lead_tx_relation", joinColumns = @JoinColumn(name = "lead_id"), inverseJoinColumns = @JoinColumn(name = "lead_tx_id"))
private Set<LeadTranscrations> LeadTranscrations;

1 个答案:

答案 0 :(得分:0)

我认为在LeadTranscrations班级中您有transDate作为列属性

这个

private Set<LeadTranscrations> leadTranscrations;

您可以使用查询方法

List<Lead> findByLeadTranscrationsTransDate(Date transDate);

您还可以通过

添加订单
List<Lead> findByLeadTranscrationsTransDateOrderByTransDateAsc(Date transDate);