-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Saving Object
PostPosted: Thu Apr 16, 2009 9:38 am 
Newbie

Joined: Thu Apr 16, 2009 9:25 am
Posts: 5
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 16, 2009 12:48 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 10:39 am
Posts: 115
Hi,

according to your constructor
Payment(Customer customer, Integer agreementId, String customerAlias)

you can't create a Paymnet with three ints!

Greetings Michael


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.