Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Hibernate Hibernate pojo example
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


James
Hibernate pojo example
2 Answer(s)      6 years and 10 months ago
Posted in : Hibernate


I need a simple Hibernate Pojo example


Advertisement
View Answers

April 19, 2008 at 8:26 PM


hi,

pojoexample.java

package roseindia;

import org.hibernate.*;
import org.hibernate.criterion.*;
import org.hibernate.cfg.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import java.util.*;

public class pojoexample {
public static void main(String arg[]){
Session session = null;
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
org.hibernate.Transaction tx = session.beginTransaction();
System.out.println("Insert data into database");
HibernatePojoExample pojo = new HibernatePojoExample();

pojo.setUsername("amardeep");
pojo.setLastname("Patel");
pojo.setAddress("rohini,delhi-85");
pojo.setQualification("MCA");
pojo.setState("delhi");
session.save(pojo);
tx.commit();
session.flush();
session.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
finally{
}
}
}



hibernate mapping


<class name="roseindia.HibernatePojoExample" table="pojoinformation">
<id name="id" type="int" column="id" >
<generator class="assigned"/>
</id>

<property name="username">
<column name="username" />
</property>
<property name="lastname">
<column name="lastname"/>
</property>
<property name="address">
<column name="address"/>
</property>
<property name="qualification">
<column name="qualification"/>
</property>

<property name="state">
<column name="state"/>
</property>

</class>


April 19, 2008 at 8:28 PM


HibernatePojoExample.java

package roseindia;

public class HibernatePojoExample {

private String username;
private String lastname;
private String address;
private String qualification;
private String state;
private int id;

public String getUsername(){
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}

public String getQualification(){
return qualification;
}
public void setQualification(String qualification){
this.qualification = qualification;
}
public String getState(){
return state;
}
public void setState(String state){
this.state = state;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}

--------------------------------------

read for more information,

http://www.roseindia.net/hibernate/

hope it will help u


Related Tutorials/Questions & Answers:
pojo generation - Hibernate
pojo generation  Can we create a pojo from a data of two different tables
Hibernate create POJO classes
Hibernate create POJO classes In this tutorial you will learn how to create a POJO class in Hibernate. POJO (Plain Old Java Object) is a programming model... be avoidable because hibernate's feature proxies depends upon the POJO
Advertisements
hibernate pojo setter method problem
hibernate pojo setter method problem  how to pass a date type variable to a setter method in hibernate pojo class? //this is my pojo class import java.util.*; public class Employee { private String empname; private int
Hibernate Example
This tutorial illustrate an example of hibernate
Pojo and java beans
of mapping file in hibernate framework. Can I use pojo class in those applications where I don't use any database and how ? Please give any example. Can I use pojo..., you can use POJO class with JSP and Servlets also. Here is an example of POJO
Hibernate Criteria And Or Example
Hibernate Criteria And Or Example  Hibernate Criteria And Or Example I want example of Hibernate Criteria And Or in Java Thanks   Example of Hibernate Criteria And Or Criteria Check the tutorial Hibernate Criteria
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  What is the example of Dirty Checking in Hibernate? Give me some of the example code? Thanks
Hibernate criteria date Example
Hibernate criteria date Example  Example of Hibernate criteria date. Check the tutorial hibernate criteria date. Check the Latest tutorials, articles and examples of Hibernate Framework. Thanks
Hibernate Criteria Count Example
Hibernate Criteria Count Example  Example of Hibernate Criteria Count. Check the tutorial Hibernate Criteria Count. Check the Latest tutorials, articles and examples of Hibernate Framework. Thanks
hibernate annotations example for mappings
hibernate annotations example for mappings  Please send me example of hibernate annotations for mappings.Please send the example   Please go through the following link: Hibernate Annotations
Simple Example of Hibernate 4
Simple Example of Hibernate 4  Hi, As a new comer in the Hibernate.... Share me the best example. Thanks   Hi, Check tutorial: Hibernate 4 Simple Example More Tutorials for a beginner: Hibernate Tutorials Home page
Dialect in Hibernate Example
Dialect in Hibernate Example   I want example of Dialect in Hibernate...   List of Dialect in Hibernate ORM framework. Check the tutorial Dialect in Hibernate. Check the Latest tutorials, articles and examples of Hibernate
Hibernate criteria average Example
Hibernate criteria average Example   How to find the average in Hibernate? Thanks   Example of finding average on a filed in Hibernate... the tutorial Hibernate criteria avg.. Check the Latest tutorials, articles
Hibernate Criteria With Collections Example
Hibernate Criteria With Collections Example  Good code of Hibernate Criteria With Collections Example. Thanks   Example program of using Hibernate Criteria With Collections in your Java project. Check the tutorial
Hibernate Criteria Between Example
Hibernate Criteria Between Example  How to use the Between in the Hibernate Query? Share me good example code. Thanks   Example of Hibernate Criteria Between. Check the tutorial Hibernate Criteria Between. Check
Hibernate Criteria And Restrictions Example
Hibernate Criteria And Restrictions Example  How to use Criteria And Restrictions in Hibernate? Thanks   I will provide you the example code of Hibernate Criteria And Restrictions. Check the tutorial Hibernate
Hibernate Spring Example
In this section, you will learn how to Integration Hibernate with Spring with an example
Hibernate criteria for date. Example
Hibernate criteria for date. Example  What to use the Hibernate criteria for date in Hibernate based application? I want example of Hibernate criteria for date in Hibernate orm. Thanks   Example of Hibernate criteria
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  Hi, What is Dirty Checking In Hibernate? Explain me with the help of Example. Thanks   The Dirty Checking In Hibernate is an mechanism for automatically detects the changes
Explain Hibernate Relationships with example.
Explain Hibernate Relationships with example.  Hello, Please explain various hibernate relationships. And if you can provide some examples that would be a great help.. Thank you....   Hi, Hibernate relational
hibernate criteria disjunction Example
hibernate criteria disjunction Example  I want example of hibernate criteria disjunction. Thanks   Example of hibernate criteria disjunction. Please check the tutorial hibernate criteria disjunction. This tutorial
Hibernate Detached Criteria Example
is useful when Hibernate session is not available. Check the example of Hibernate...Hibernate Detached Criteria Example  How to use Hibernate Detached Criteria in Java program? What is the use of Hibernate Detached Criteria? Explain
Hibernate Criteria Wildcard Example
want example of Hibernate Criteria Wildcard which is easy to understand. Thanks   Example tutorial in Hibernate for getting the data through...Hibernate Criteria Wildcard Example  Hi, How to write Java program
Hibernate Detached Criteria Example
Hibernate Detached Criteria Example  can anyone share me the source code of using detached Criteria in Hibernate? Thanks   Hi, If you are looking for the Example program of using Hibernate Detached Criteria
Dirty Checking In Hibernate Example
Dirty Checking In Hibernate Example  What is the example of Dirty Checking in Hibernate? Give me some of the example code? Thanks   The Dirty Checking In Hibernate is used to track the status of the entity and detect
Hibernate Criteria Transformer Example
Hibernate Criteria Transformer Example  I want example of Hibernate...   Here I am giving you the link of Hibernate Criteria Transforme example program. Check the tutorial Hibernate Criteria Transformer . Check the Latest
Hibernate 4 Example with Eclipse
Hibernate 4 Example with Eclipse   I am a beginner and want to know about the Hibernate 4 Example with Eclipse and how to install it. Can someone... can do first Example of Hibernate with Eclipse and below link can help you
Hibernate delete example program
Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate... session.delete(emp); Check the tutorial Hibernate Session.delete() Example
Hibernate Criteria Query Example
Hibernate Criteria Query Example  Hi, How to create Hibernate Criteria Query Examples in Java program? Share me the easy to learn example code. Thanks   Hi, Hibernate Criteria Query is used to selectively find
hibernate by example
In this tutorial you will learn hibernate by example with ready made downloadable source code
pojo class having problem
pojo class having problem  Cannot find any information on property 'Username' in a bean of type 'LoginBean.LoginBeanClass' org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:664
Advertisements
 

 

 

DMCA.com