私は2つのオブジェクトCustomer
とCustomerAcctSetting
. CustomerAcctSetting
は外部キーを持っていますCUSTOMER_ID
。私の問題はCustomer
、関連付けられたオブジェクトを取得できず、CustomerAcctSetting
null のみを返すオブジェクトを取得することです。
以下は、2 つの休止状態オブジェクトです。
Customer.java
@Entity
@Table(name = "CUSTOMER")
public class Customer extends BaseDomain{
.
.
.
private CustomerAcctSetting customerAcctSetting;
@Id
@Override
@GeneratedValue(generator = "increment")
@GenericGenerator (name = "increment", strategy = "increment")
@Column (name = "CUSTOMER_ID", unique = true, nullable = false, insertable = false, updatable = false)
public int getId() {
return super.getId();
}
.
.
.
@OneToOne
@JoinColumn(name = "CUSTOMER_ID")
public CustomerAcctSetting getCustomerAcctSetting() {
return customerAcctSetting;
}
public void setCustomerAcctSetting(CustomerAcctSetting customerAcctSetting) {
this.customerAcctSetting = customerAcctSetting;
}
}
CustomerAcctSetting.java
@Entity
@Table(name = "CUSTOMER_ACCT_SETTING")
public class CustomerAcctSetting extends BaseDomain{
private int customerId;
.
.
.
@Id
@Override
@GeneratedValue(generator = "increment")
@GenericGenerator (name = "increment", strategy = "increment")
@Column (name = "CUSTOMER_ACCT_SETTING_ID", unique = true, nullable = false, insertable = false, updatable = false)
public int getId() {
return super.getId();
}
.
.
.
@Column(name = "CUSTOMER_ID")
public int getCustomerId() {
return customerId;
}
public void setCustomerId(int customerId) {
this.customerId = customerId;
}
}
から取得する必要がないためCustomer
、 のマッピングは含めませんでした。だけ入れました。CustomerAcctSetting
Customer
CustomerAcctSetting
CUSTOMER_ID
CustomerAcctSetting
助けてください。前もって感謝します。