単純な基準を実行しようとしていますが、「org.hibernate.QueryException:プロパティを解決できませんでした。 実際、ProcessInstanceJPAに対して条件を適用する必要がありますが、ExpenseHeaderJPAのprocessInstanceJPAは認識されません。org.hibernate.QueryExceptionの取得中:プロパティが完全に同じであっても、プロパティは完全に同じです
基準:
List<ExpenseHeaderJPA> expsensHeaderList= session.createCriteria(ExpenseHeaderJPA.class)
.add(Restrictions.eq("processInstanceJPA.processInstanceId", new Long(1))
.list();
ProcessInstaceJPA
@Entity
@Table(name="process_instance")
public class ProcessInstanceJPA {
@Id @GeneratedValue
@Column(name="process_instance_id")
private Long processInstanceId;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="expense_header_id")
/*@OneToOne
@PrimaryKeyJoinColumn*/
private ExpenseHeaderJPA expenseHeaderJPA;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="voucher_status_id")
private VoucherStatusJPA voucherStatusJPA;
@OneToOne(fetch=FetchType.LAZY)
@JoinColumn(name="pending_at")
private EmployeeJPA pendingAt;
public Long getProcessInstanceId() {
return processInstanceId;
}
public void setProcessInstanceId(Long processInstanceId) {
this.processInstanceId = processInstanceId;
}
public ExpenseHeaderJPA getExpenseHeaderJPA() {
return expenseHeaderJPA;
}
public void setExpenseHeaderJPA(ExpenseHeaderJPA expenseHeaderJPA) {
this.expenseHeaderJPA = expenseHeaderJPA;
}
public VoucherStatusJPA getVoucherStatusJPA() {
return voucherStatusJPA;
}
public void setVoucherStatusJPA(VoucherStatusJPA voucherStatusJPA) {
this.voucherStatusJPA = voucherStatusJPA;
}
public EmployeeJPA getPendingAt() {
return pendingAt;
}
public void setPendingAt(EmployeeJPA pendingAt) {
this.pendingAt = pendingAt;
}
}
ExpenseHeaderJPA
@Entity
@Table(name="expense_header")
public class ExpenseHeaderJPA {
@Id @GeneratedValue
@Column(name="expense_header_id")
private Long expenseHeaderId;
@OneToMany(orphanRemoval=true,mappedBy="expenseHeaderJPA",fetch=FetchType.EAGER)
@Cascade({CascadeType.ALL})
@Fetch (FetchMode.SELECT)
private List<ExpenseDetailJPA> expenseDetailJPA;
@OneToMany(orphanRemoval=true,mappedBy="expenseHeaderJPA",fetch=FetchType.EAGER)
@Cascade({CascadeType.ALL})
@Fetch (FetchMode.SELECT)
private List<ProcessHistoryJPA> processHistoryJPA;
@OneToOne(orphanRemoval=true,mappedBy="expenseHeaderJPA",fetch=FetchType.EAGER)
@Cascade({CascadeType.ALL})
@Fetch (FetchMode.SELECT)
private ProcessInstanceJPA processInstanceJPA;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "employee_id")
private EmployeeJPA employeeJPA;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "voucher_status")
private VoucherStatusJPA voucherStatusJPA;
@Column(name="start_date")
private Calendar startDate;
@Column(name="end_date")
private Calendar endDate;
@Column(name="title")
private String title;
@Column(name="purpose")
private String purpose;
public Long getExpenseHeaderId() {
return expenseHeaderId;
}
public void setExpenseHeaderId(Long expenseHeaderId) {
this.expenseHeaderId = expenseHeaderId;
}
public Calendar getStartDate() {
return startDate;
}
public void setStartDate(Calendar startDate) {
this.startDate = startDate;
}
public Calendar getEndDate() {
return endDate;
}
public void setEndDate(Calendar endDate) {
this.endDate = endDate;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
public List<ExpenseDetailJPA> getExpenseDetailJPA() {
return expenseDetailJPA;
}
public void setExpenseDetailJPA(List<ExpenseDetailJPA> expenseDetailJPA) {
this.expenseDetailJPA = expenseDetailJPA;
}
public EmployeeJPA getEmployeeJPA() {
return employeeJPA;
}
public void setEmployeeJPA(EmployeeJPA employeeJPA) {
this.employeeJPA = employeeJPA;
}
public VoucherStatusJPA getVoucherStatusJPA() {
return voucherStatusJPA;
}
public List<ProcessHistoryJPA> getProcessHistoryJPA() {
return processHistoryJPA;
}
public void setProcessHistoryJPA(List<ProcessHistoryJPA> processHistoryJPA) {
this.processHistoryJPA = processHistoryJPA;
}
public void setVoucherStatusJPA(VoucherStatusJPA voucherStatusJPA) {
this.voucherStatusJPA = voucherStatusJPA;
}
public ProcessInstanceJPA getProcessInstanceJPA() {
return processInstanceJPA;
}
public void setProcessInstanceJPA(ProcessInstanceJPA processInstanceJPA) {
this.processInstanceJPA = processInstanceJPA;
}
}
ExpenseHeaderJPAは、親テーブルであるとProcessInstanceJPAは、子テーブルです。それらの間にOnetoOneマッピングがあります。 ProcessInstaceJPAのプロパティに制限を適用しようとすると、無効なプロパティエラーが発生します。
MySQLデータベースの構造は:
CREATE TABLE `expense_header` (
`expense_header_id` bigint(10) NOT NULL AUTO_INCREMENT,
....
....
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
CREATE TABLE `process_instance` (
`process_instance_id` bigint(10) NOT NULL AUTO_INCREMENT,
`expense_header_id` bigint(10) NOT NULL,
...
...
)
この問題を解決するのに役立ちます。
ので、あなたはそれの後に物事を呼ぶ理由がないアイデア:
あなたはこのような何かを行うことができます。 –