Frameworks| Hibernate| Struts| JSF| JavaFX| Ajax| Spring| DOJO| JDO| iBatis| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Writing ORM for Insurance table 
 

In this lesson we will write the java class and add necessary code in the contact.hbm.xml file.

 

Writing ORM for Insurance table

                         

In this lesson we will write the java class and add necessary code in the contact.hbm.xml file.

Create POJO class:
Here is the code of our java file (Insurance.java), which we will map to the insurance table.


 

 

 

 


package roseindia.tutorial.hibernate;

import java.util.Date;
/**
 @author Deepak Kumar
 *
 * http://www.roseindia.net
 * Java Class to map to the database insurance table
 */
public class Insurance {
  private long lngInsuranceId;
  private String insuranceName;
  private int investementAmount;
  private Date investementDate;
  
  /**
   @return Returns the insuranceName.
   */
  public String getInsuranceName() {
    return insuranceName;
  }
  /**
   @param insuranceName The insuranceName to set.
   */
  public void setInsuranceName(String insuranceName) {
    this.insuranceName = insuranceName;
  }
  /**
   @return Returns the investementAmount.
   */
  public int getInvestementAmount() {
    return investementAmount;
  }
  /**
   @param investementAmount The investementAmount

 to set.
   */
  public void setInvestementAmount(int investementAmount)

 {
    this.investementAmount = investementAmount;
  }
  /**
   @return Returns the investementDate.
   */
  public Date getInvestementDate() {
    return investementDate;
  }
  /**
   @param investementDate The investementDate to set.
   */
  public void setInvestementDate(Date investementDate) {
    this.investementDate = investementDate;
  }
  /**
   @return Returns the lngInsuranceId.
   */
  public long getLngInsuranceId() {
    return lngInsuranceId;
  }
  /**
   @param lngInsuranceId The lngInsuranceId to set.
   */
  public void setLngInsuranceId(long lngInsuranceId) {
    this.lngInsuranceId = lngInsuranceId;
  }
}

Adding mappings into  contact.hbm.xml file
Add the following code into 
contact.hbm.xml file.


 <class name="roseindia.tutorial.hibernate.
Insurance" table="insurance">
		<id name="lngInsuranceI
d" type="long" column="ID" > <generator class="increment"/> </id> <property name="insuranceName"> <column name="insurance_name" /> </property> <property name="investementAmount"> <column name="invested_amount" /> </property> <property name="investementDate"> <column name="investement_date" /> </property> </class>

Now we have created the POJO class and necessary mapping into contact.hbm.xml file. 

                         

» View all related tutorials
Related Tags: sql c hibernate api query com inheritance class server collections table date select update delete object insert style io connection

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

I am really got benefited by your tutorial.Hope u will continue publishing such good ones...

Posted by kanchan saha on Friday, 08.17.07 @ 13:47pm | #23583

This POJO class is automatically generated in MyEclipse , so better use MyEclipse IDE for hibernate , its very powerful tool to work with.

Posted by John on Wednesday, 03.14.07 @ 10:06am | #11647

Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.