我需要以下查询才能转换为条件构建器。
value toPMML is not a member of org.apache.spark.ml.tuning.CrossValidatorModel
实体类:
SELECT event0_.event_id AS event_id1_4_0_,
emailcommu1_.email_recipient_id AS email_re1_2_1_,
smscommuni2_.sms_recipient_id AS sms_reci1_8_2_,
event0_.created_by AS created_2_4_0_,
event0_.created_on AS created_3_4_0_,
event0_.updated_by AS updated_4_4_0_,
event0_.updated_on AS updated_5_4_0_,
event0_.email_template_followed AS email_te6_4_0_,
event0_.event_code AS event_co7_4_0_,
event0_.event_module_identifier AS event_mo8_4_0_,
event0_.event_name AS event_na9_4_0_,
event0_.is_deleted AS is_dele10_4_0_,
event0_.event_template_recipient AS event_t11_4_0_,
event0_.pref_email AS pref_em12_4_0_,
event0_.pref_hard_copy AS pref_ha13_4_0_,
event0_.pref_letter_hard_copy AS pref_le14_4_0_,
event0_.pref_portal_app AS pref_po15_4_0_,
event0_.pref_sms AS pref_sm16_4_0_,
event0_.sms_template_followed AS sms_tem17_4_0_,
event0_.trigger_point AS trigger18_4_0_,
emailcommu1_.created_by AS created_2_2_1_,
emailcommu1_.created_on AS created_3_2_1_,
emailcommu1_.updated_by AS updated_4_2_1_,
emailcommu1_.updated_on AS updated_5_2_1_,
emailcommu1_.event_id AS event_id8_2_1_,
emailcommu1_.is_deleted AS is_delet6_2_1_,
emailcommu1_.recipient_group_id AS recipien9_2_1_,
emailcommu1_.recipient_type_id AS recipien7_2_1_,
emailcommu1_.event_id AS event_id8_4_0__,
emailcommu1_.email_recipient_id AS email_re1_2_0__,
smscommuni2_.created_by AS created_2_8_2_,
smscommuni2_.created_on AS created_3_8_2_,
smscommuni2_.updated_by AS updated_4_8_2_,
smscommuni2_.updated_on AS updated_5_8_2_,
smscommuni2_.event_id AS event_id7_8_2_,
smscommuni2_.is_deleted AS is_delet6_8_2_,
smscommuni2_.recipient_group_id AS recipien8_8_2_,
smscommuni2_.event_id AS event_id7_4_1__,
smscommuni2_.sms_recipient_id AS sms_reci1_8_1__
FROM communication.event_master event0_
LEFT OUTER JOIN communication.email_communication_recipient emailcommu1_
ON event0_.event_id = emailcommu1_.event_id
AND emailcommu1_.is_deleted = 'N'
LEFT OUTER JOIN communication.sms_communication_recipient smscommuni2_
ON event0_.event_id = smscommuni2_.event_id
AND smscommuni2_.is_deleted = 'N'
WHERE event0_.event_id = 51
公共类Event扩展BaseModel实现了Serializable {
@Entity
@Table(name = "communication.event_master")
EmailCommunication收件人:
public Event() {
}
public Event(Integer eventId, String eventCode, String eventName, String eventModule, Character prefSMS,
Character prefEmail, Character prefHardCopy, String eventTemplate) {
super();
this.eventId = eventId;
this.eventCode = eventCode;
this.eventName = eventName;
this.eventModule = eventModule;
this.prefSMS = prefSMS;
this.prefEmail = prefEmail;
this.prefHardCopy = prefHardCopy;
this.eventTemplate = eventTemplate;
}
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "eventid_generator")
@SequenceGenerator(name = "eventid_generator", sequenceName = "communication.event_seq", allocationSize = 1)
@Column(name = "event_id", unique = true, nullable = false)
private Integer eventId;
@Column(name = "event_name")
private String eventName;
@Column(name = "event_module_identifier")
private String eventModule;
@Column(name = "event_code")
private String eventCode;
@Column(name = "trigger_point")
private String triggerPoint;
@Column(name = "event_template_recipient")
private String eventTemplate;
@Column(name = "pref_email")
private Character prefEmail;
@Column(name = "pref_hard_copy")
private Character prefHardCopy;
@Column(name = "pref_sms")
private Character prefSMS;
@Column(name = "pref_portal_app")
private Character prefPortalApp;
@Column(name = "pref_letter_hard_copy")
private Character prefLetterHardCopy;
@Column(name = "email_template_followed")
private String emailTemplateFollowed;
@Column(name = "sms_template_followed")
private String smsTemplateFollowed;
@Column(name = "is_deleted")
private Character eventStatus;
@OneToMany(mappedBy = "event",fetch=FetchType.LAZY)
private Set<SmsTemplateMaster> smsTemplateMaster;
@OneToMany(mappedBy = "event",fetch=FetchType.LAZY)
private Set<EmailTemplateMaster> emailTemplateMaster;
@OneToMany(mappedBy = "event",fetch=FetchType.LAZY)
private Set<SMSCommunicationRecipient> smsCommunicationRecipient;
@OneToMany(mappedBy = "event",fetch=FetchType.LAZY)
private Set<EmailCommunicationRecipient> emailCommunicationRecipient;
}
SMSCommunicationRecipient:
@Entity
@Table(name = "communication.email_communication_recipient")
public class EmailCommunicationRecipient extends BaseModel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "email_recipientid_generator")
@SequenceGenerator(name = "email_recipientid_generator", sequenceName = "communication.email_recipient_id_seq", allocationSize = 1)
@Column(name = "email_recipient_id", unique = true, nullable = false)
private Integer emailRecipientId;
@ManyToOne
@JoinColumn(name = "recipient_group_id", referencedColumnName = "reference_data_id")
private CommunicationReferenceData recipientGroupId;
@Column(name = "recipient_type_id")
private String recipientTypeId;
@Column(name = "is_deleted")
private Character isDeleted;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "event_id", nullable = false)
private Event event;
}
我已经按如下所示创建了我的条件构建器。
@Entity
@Table(name = "communication.sms_communication_recipient")
public class SMSCommunicationRecipient extends BaseModel implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sms_recipientid_generator")
@SequenceGenerator(name = "sms_recipientid_generator", sequenceName = "communication.sms_recipient_id_seq", allocationSize = 1)
@Column(name = "sms_recipient_id", unique = true, nullable = false)
private Integer smsRecipientId;
@ManyToOne
@JoinColumn(name = "recipient_group_id", referencedColumnName = "reference_data_id")
private CommunicationReferenceData recipientGroupId;
@Column(name = "is_deleted")
private Character isDeleted;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "event_id", nullable = false)
private Event event;
}
这将生成以下SQL查询。
List<Predicate> conditions = new ArrayList<>();
CriteriaBuilder builder = manager.getCriteriaBuilder();
CriteriaQuery<Event> criteriaQuery = builder.createQuery(Event.class);
Root<Event> root = criteriaQuery.from(Event.class);
/*Join<Event, EmailCommunicationRecipient> joinEmailRecipient = root.join(Event_.emailCommunicationRecipient, JoinType.LEFT);
Join<Event, SMSCommunicationRecipient> joinSMSRecipient = root.join(Event_.smsCommunicationRecipient, JoinType.LEFT);
root.fetch(Event_.emailCommunicationRecipient, JoinType.LEFT);
root.fetch(Event_.smsCommunicationRecipient, JoinType.LEFT);*/
Join<Event, EmailCommunicationRecipient> joinEmailRecipient = (Join<Event, EmailCommunicationRecipient>) root.fetch(Event_.emailCommunicationRecipient, JoinType.LEFT);
//Join<EmailCommunicationRecipient, CommunicationReferenceData> joinEmailRefernce = (Join<EmailCommunicationRecipient, CommunicationReferenceData>) root.fetch(EmailCommunicationRecipient_.recipientGroupId, JoinType.INNER);
Join<Event, SMSCommunicationRecipient> joinSMSRecipient = (Join<Event, SMSCommunicationRecipient>) root.fetch(Event_.smsCommunicationRecipient, JoinType.LEFT);
criteriaQuery.select(root);
criteriaQuery.where(builder.equal(root.get(Event_.eventId), eventId),builder.equal(joinEmailRecipient.get(EmailCommunicationRecipient_.isDeleted), CommunicationConstants.FLAG_N),
builder.equal(joinSMSRecipient.get(SMSCommunicationRecipient_.isDeleted), CommunicationConstants.FLAG_N));
Query query = manager.createQuery(criteriaQuery);
List<Event> eventList = query.getResultList();
Event event = null;
if (null != eventList && !eventList.isEmpty()) {
event = eventList.get(0);
}
我只需要将AND条件应用于左外部JOIN。
如何在“标准构建器”中实现这一目标