Hi Experts,
I have this POJO;
Code:
public class Payment implements java.io.Serializable {
private Integer id;
private Customer customer;
private Integer agreementId;
private String customerAlias;
public Payment() {
}
public Payment(Customer customer, Integer agreementId, String customerAlias) {
this.customer = customer;
this.agreementId = agreementId;
this.customerAlias = customerAlias;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public Customer getCustomer() {
return this.customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public Integer getAgreementId() {
return this.agreementId;
}
public void setAgreementId(Integer agreementId) {
this.agreementId = agreementId;
}
public String getCustomerAlias() {
return this.customerAlias;
}
public void setCustomerAlias(String customerAlias) {
this.customerAlias = customerAlias;
}
}
Whith this mapping;
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 16-Apr-2009 10:18:36 by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class catalog="test" name="com.port.pojo.Payment" table="payment">
<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="identity"/>
</id>
<many-to-one class="com.port.pojo.Customer" fetch="select" name="customer">
<column name="customer_id"/>
</many-to-one>
<property name="agreementId" type="java.lang.Integer">
<column name="Agreement_id"/>
</property>
<property name="customerAlias" type="string">
<column length="50" name="customer_alias"/>
</property>
</class>
</hibernate-mapping>
I am trying to do something like this to save the Payment Object;
Code:
Session session =
HibernateUtil.getSessionFactory().openSession();
Transaction tx = session.beginTransaction();
Payment payment = new Payment(23, 25, 25);
session.save(payment);
tx.commit();
session.close();
my problem is this part of the code;
Payment payment = new Payment(23, 25, 25); is highlighted as error, can someone tell me what i am doing wrong?
please help.