Hi,
I'm experimenting a bit with hibernate at the moment and a simple problem occured, my class PaymentSummary contains
Code:
public class Payment {
private Long paymentId;
private ValueDate creditValueDate;
private ValueDate debitValueDate;
public Payment() {
}
public Long getPaymentId() {
return paymentId;
}
public ValueDate getCreditValueDate() {
return creditValueDate;
}
public ValueDate getDebitValueDate() {
return debitValueDate;
}
public void setPaymentId(Long paymentId) {
this.paymentId = paymentId;
}
public void setCreditValueDate(ValueDate date) {
creditValueDate = date;
}
public void setDebditValueDate(ValueDate date) {
debitValueDate = date;
}
}
AND
Code:
public class ValueDate {
private Long valueDateId = null;
private Date date = null;
private String tag = null;
public ValueDate() {
}
public Long getValueDateId() {
return valueDateId;
}
public void setValueDateId(Long long1) {
valueDateId = long1;
}
public Date getDate(){
return date;
}
public void setDate(Date date) {
this.date = date;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
}
What would the mapping of Payment look like? I don't succeed in storing the creditValueDate and debitValueDate.
The mapping of ValueDate would look like:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="eg.ValueDate" table="VALUEDATE">
<id name="valueDateId" column="valueDateId" type="long">
<generator class="increment"/>
</id>
<property name="date" type="date"/>
<property name="tag" type="string"/>
</class>
</hibernate-mapping>
I tried to let hibernate "autodetect" the type of properties creditValueDate and debitValueDate. I've put the type hardcode, but none of those work.
Then I've tried to put a one-to-one for each of the properties, but that also doesn't work correctly (key problem).
How should I do this nicely?
Kind regards
B