Hibernate SessionFactory

Hibernate SessionFactory

Can anyone please give me an example of Hibernate SessionFactory?

View Answers

April 26, 2008 at 12:54 PM

Hi friend,

package roseindia;

import org.hibernate.*;
import org.hibernate.criterion.*;
import org.hibernate.cfg.*;

import java.util.*;

public class StoreprocedureExam {
public static void main(String arg[]){
Session session = null;
try {
SessionFactory sessionFactory = new Configuration().configure()
.buildSessionFactory();
session = sessionFactory.openSession();
String SQL_QUERY ="from Procedure proced";
Query query = session.createQuery(SQL_QUERY);
for(Iterator it=query.iterate();it.hasNext();){
Procedure procedure=(Procedure)it.next();

System.out.println("Id:"+procedure.getId());
System.out.println("Name:"+procedure.getUsername());
System.out.println("CLass:"+procedure.getRoom());
System.out.println("Address:"+procedure.getAddress());
System.out.println("Father name:"+procedure.getFaname());

}
session.close();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
finally {
}
}

}
--------------------------

April 26, 2008 at 12:56 PM

This is mapping code,

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">;

<hibernate-mapping>

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

<property name="username">
<column name="username" />
</property>
<property name="room">
<column name="room"/>
</property>
<property name="address">
<column name="address"/>
</property>
<property name="faname">
<column name="faname"/>
</property>


</class>
</hibernate-mapping>


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

package roseindia;

public class Procedure {
private String username;
private String room;
private String address;
private String faname;
private int id;

public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}

public String getFaname(){
return faname;
}
public void setFaname(String faname){
this.faname = faname;
}

}

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

read for more information,

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









Related Tutorials/Questions & Answers:
Create sessionfactory in Hibernate 4
Create sessionfactory in Hibernate 4  How to create sessionfactory in Hibernate 4? Thanks
SessionFactory interface in Hibernate
SessionFactory interface in Hibernate  What is SessionFactory interface in Hibernate?   The application obtains Session instances from a SessionFactory.There is typically a single SessionFactory for the whole
Advertisements
What is Hibernate sessionfactory
What is Hibernate sessionfactory  Hi, I am new in Hibernate. I trying to write a simple program in Hibernate. Can anyone explain me about the hibernate sessionfactory? Thanks
Please explain Hibernate Sessionfactory.
Please explain Hibernate Sessionfactory.  Hi there, Please explain Hibernate session factory in detail. I have just started learning hibernate so i... session factory - Hibernate SessionFactory Hibernate SessionFactory Example
How to use Hibernate get sessionfactory?
How to use Hibernate get sessionfactory?  Hi, How to use hibernate get sessionfactory? Thanks
Hibernate SessionFactory
Hibernate SessionFactory In this tutorial we will learn about how the SessionFactory creates the session. SessionFactory is an interface that extends.... In an application the SessionFactory instance is globally created and is thread
How to create sessionfactory in Hibernate 4.1.1?
How to create sessionfactory in Hibernate 4.1.1?  HI, I need to create Sessionfactory in Hibernate 4.1.1. How can i do it? Thanks.   ... in hibernate 4.1.1: Hibernate 4 create Session Factory How to create SessionFactory
How to create sessionfactory in Hibernate 4.1?
How to create sessionfactory in Hibernate 4.1?  hi, I have worked... sessionfactory in hibernate 4.1.. Thanks in advance   Dear Friend, Following links might come handy to you in creating sessionfactory in Hibernate 4
Why we use singleton class in hibernate sessionfactory?
Why we use singleton class in hibernate sessionfactory?  Hello, Please tell me why we use singleton class in hibernate sessionfactory? hibernate sessionfactory singleton example would be very helpful. Thanks
How to get hibernate configuration from sessionfactory?
How to get hibernate configuration from sessionfactory?  Hi, I need to get hibernate configuration from sessionfactory, how can i do it? Thanks... sessionfactory - Hibernate SessionFactory Example Hibernate SessionFactory Read moe
what is the use of Hibernate Sessionfactory close() method?
what is the use of Hibernate Sessionfactory close() method?  hi, What is the use of of Hibernate Sessionfactory close() method? Thanks..   Hello, Close() method of Hibernate Sessionfactory destroys the SessionFactory
Hibernate 5 SessionFactory Example
Hibernate 5 SessionFactory Example - Learn the new way to creating SessionFactory in Hibernate 5 SessionFactory plays a major role in Hibernate framework... in Hibernate 5. Hibernate 5 SessionFactory Example Now we will see the code example
Hibernate SessionFactory Example
In this example, we will learn about the getting session instance from the SessionFactory interface in Hibernate 4
How does getcurrentsession() method works in hibernate sessionfactory?
How does getcurrentsession() method works in hibernate sessionfactory?  Hi, Please explain how does getcurrentsession() method works in hibernate... about getCurrentSession() method in Hibernate sessionfactory Also you can read
How to create SessionFactory in Hibernate 4.3.1?
Learn How to create SessionFactory in Hibernate 4.3.1? You you know Hibernate... we are describing the code to create SessionFactory in Hibernate 4.3.x.... the SessionFactory in the Hibernate 4.3.0, 4.3.1 and above releases
Hibernate 5 build SessionFactory Example
Example of building SessionFactory in Hibernate 5 In this tutorial we are going to see the new way of building SessionFactory in Hibernate 5. Hibernate 5... the way of building SessionFactory. In Hibernate based application the instance
How can I create sessionfactory in Hibernate?
How can I create sessionfactory in Hibernate?  HELLO, How can I create sessionfactory in Hibernate? If you can explain me with example that would... Session Factory in Hibernate 4 Besides, read about Hibernate 4 and Session Factory
Hibernate : SessionFactory
In this section we will discuss concept of SessionFactory
I want to build sessionfactory in hibernate 4. Need help.
I want to build sessionfactory in hibernate 4. Need help.  Hello, I want to build sessionfactory in hibernate 4. Need help
Can you give me a simple Hibernate Sessionfactory example?
Can you give me a simple Hibernate Sessionfactory example?  Hi, I would like to get session instance from the SessionFactory interface in Hibernate 4. Can you give me a simple Hibernate Sessionfactory example for the above
I am having problem with configuring Hibernate sessionfactory. Please Help
I am having problem with configuring Hibernate sessionfactory. Please Help  Sir, I am having problem with configuring Hibernate sessionfactory.. I was using the old version of Hibernate before now I am using Hibernate 4
Hibernate Error: Failed to create sessionFactory object.java.lang.NoClassDefFoundError
In this video you will learn why this error comes in the Hibernate project and how to solve the error? While working on a Hibernate/Java based after update of some of the jar file of the old version of Hibernate to new version
I would like an example about how to create a sessionfactory in Hibernate 4?
I would like an example about how to create a sessionfactory in Hibernate 4?  Hello, Since Hibernate 4 is the latest version of Hibernate, I am finding it a little difficult to create Session factory in Hibernate 4. If you can
I want to know how can I create sessionfactory in hibernate 4 (latest version)
I want to know how can I create sessionfactory in hibernate 4 (latest version)  Hello, I want to create sessionfactory in hibernate 4 (latest version) and I would like your help for it..An example would be of great help
Hibernate - Hibernate
Hibernate sessionfactory configuration  What is the process of hibernate sessionfactory configuration
Hibernate 5 annotationconfiguration
Hibernate and manually creating SessionFactory in your program... In this tutorial we will talk about how to create SessionFactory and get session in Hibernate... Example How to create SessionFactory in Hibernate 5? Hibernate 5
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
Hibernate: core interfaces of hibernate framework
Hibernate: core interfaces of hibernate framework  What are the core interfaces of hibernate framework   Most of hibernate based application code deals with following interfaces provided by the Hibernate Core
hibernate - Hibernate
Hibernate; import org.hibernate.Session; import org.hibernate.*; import... static void main(String[] args) { Session session = null; try{ SessionFactory sessionFactory = new Configuration().configure() .buildSessionFactory
Hibernate - Hibernate
Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import...[]){ Session session = null; try { SessionFactory sessionFactory = new
Struts2.2.1 and hibernate integration application
. HibernateUtil class is a helper class that handle Hibernate's SessionFactory...Struts2.2.1 and hibernate integration application HibernateUtil.java Description The HibernateUtil is a java class which provides SessionFactory from
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate flow
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  how to uses optional column in hibernate
hibernate
hibernate  please give me the link where i can freely download hibernate software(with dependencies)   Learn hibernate, if you want to learn hibernate, please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  hibernate delete query execution
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  how to use pagination concept in Hibernate
hibernate - Hibernate
Hibernate; import org.hibernate.Session; import org.hibernate.*; import...{ SessionFactory sessionFactory = new Configuration().configure...   Hi Radhika, i think, you hibernate configuration
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
StandardServiceRegistryBuilder not working in Hibernate 4.3.1
if some one shares me the code to create the SessionFactory in Hibernate 4.3.1.... the tutorial How to create SessionFactory in Hibernate 4.3.1?. Thanks...StandardServiceRegistryBuilder not working in Hibernate 4.3.1  Hi
How to create Hibernate session factory name?
Factory in Hibernate 4 Hibernate SessionFactory Hibernate : SessionFactory Hibernate Session How to create SessionFactory in Hibernate 4.3.1 Also you learn...How to create Hibernate session factory name?  Hi, I am new
hibernate - Hibernate
hibernate for use SessionFactory sessionFactory = new Configuration...hibernate  hi i am new to hibernate. i wan to run a select query with oracle database. could you please help me out. my files are: package
hibernate
why hibernate?  why hibernate?   Hibernate: -Hibernate... library. It solves object-relational impedance mismatch problems. Hibernate makes the application development process easy Hibernate saves the development
Hibernate - Hibernate
Hibernate pojo example  I need a simple Hibernate Pojo example ...[]){ Session session = null; try{ SessionFactory sessionFactory = new Configuration...){ System.out.println(e.getMessage()); } finally{ } }}hibernate mapping <class name
hibernate
hibernate  pls give one simple example program for hibernate
hibernate
hibernate  why we should use hibernate projection
Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc

Ads