Magazine
 
Hibernate Query Language
 
/*Table structure for table ‘insurance‘ */
drop table if exists ‘insurance‘;
CREATE TABLE ‘insurance‘ (
‘ID‘ int(11) NOT NULL default ‘0’,
‘insurance_name‘ varchar(50) default NULL,
‘invested_amount‘ int(11) default NULL,
‘investement_date‘ datetime default NULL,
PRIMARY KEY (‘ID‘)
) TYPE=MyISAM;
/*Data for the table ‘insurance‘ */
insert into ‘insurance‘ values (1,’Car
Insurance’,1000,’2005-01-05 00:00:00');
insert into ‘insurance‘ values (2,’Life
Insurance’,100,’2005-10-01 00:00:00');
insert into ‘insurance‘ values (3,’Life
Insurance’,500,’2005-10-15 00:00:00');
insert into ‘insurance‘ values (4,’Car
Insurance’,2500,’2005-01-01 00:00:00');
insert into ‘insurance‘ values (5,’Dental
Insurance’,500,’2004-01-01 00:00:00');
insert into ‘insurance‘ values (6,’Life
Insurance’,900,’2003-01-01 00:00:00');
insert into ‘insurance‘ values (7,’Travel
Insurance’,2000,’2005-02-02 00:00:00');
insert into ‘insurance‘ values (8,’Travel
Insurance’,600,’2005-03-03 00:00:00');
insert into ‘insurance‘ values (9,’Medical
Insurance’,700,’2005-04-04 00:00:00');
insert into ‘insurance‘ values (10,’Medical
Insurance’,900,’2005-03-03 00:00:00');
insert into ‘insurance‘ values (11,’Home
Insurance’,800,’2005-02-02 00:00:00');
insert into ‘insurance‘ values (12,’Home
Insurance’,750,’2004-09-09 00:00:00');
insert into ‘insurance‘ values (13,’Motorcycle
Insurance’,900,’2004-06-06 00:00:00');
insert into ‘insurance‘ values (14,’Motorcycle
Insurance’,780,’2005-03-03 00:00:00');

Create POJO class for Insurance table:

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

package roseindia.tutorial.hibernate;

 
import java.util.Date;
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;
Feb 2008 | Java Jazz Up |32
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,

Download PDF