Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML

Search:
   Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML Facing Programming Problem? Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Hibernate
  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. 

                         

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

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

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 | 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.