Home Answers Viewqa Hibernate Hibernate SessionFactory

 
 


hema
Hibernate SessionFactory
2 Answer(s)      5 years and 2 months ago
Posted in : Hibernate

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 Pages:
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
Hibernate : SessionFactory
In this section we will discuss concept of SessionFactory
Hibernate SessionFactory Example
In this example, we will learn about the getting session instance from the SessionFactory interface in Hibernate 4
Hibernate - Hibernate
Hibernate sessionfactory configuration  What is the process of hibernate sessionfactory configuration
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
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
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 - 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: 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 Criteria Queries - Hibernate
Configuration(); // configuring hibernate SessionFactory...Hibernate Criteria Queries  Can I use the Hibernate Criteria Query...; SessionFactory sessionFactory = new Configuration().configure
hibernate code - Hibernate
{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory...hibernate code  well deepak,Regarding the inputs u asked for my fisr
Reagrsding Hibernate joins - Hibernate
Reagrsding Hibernate joins  Hi, I am trying to make join in Hibernate...{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new Configuration().configure
java - Hibernate
problems: SessionFactory cannot be resolved to a type The method... the code and run using Hibernate and annotation..plse help me...  Hi friend, Read for more information. http://www.roseindia.net/hibernate
java(Hibernate) - Hibernate
will read hibernate.cfg.xml and prepare hibernate for use SessionFactory...java(Hibernate)  Hai Amardeep This is jagadhish.Iam giving full code...(); SessionFactory factory=cf.buildSessionFactory(); Session session=factory.openSession
Null pointer exception in hibernate - Hibernate
Null pointer exception in hibernate  Hi i am getting null pointer exception.while running the program in hibernate... exception. SessionFactory object is not creating pls give me the solution
Hibernate 4
Hibernate 4 Hibernate 4 is the latest version of Hibernate which was released in Jan, 2012. Hibernate 4 comes with many new features such as Multi-tenancy support. Hibernate is popular ORM tool in Java. It can be used with the JPA
Java - Hibernate
, this type of output. ---------------------------- Inserting Record Done Hibernate...; try{ SessionFactory sessionFactory = new Configuration... = null; try{ // This step will read hibernate.cfg.xml and prepare hibernate
Detachedcriteria in hibernate
in hibernate for given Query?   Detached Criteria query is a facility provide by Hibernate to write criteria queries in ?detached mode?, where hibernate...("Ron")); SessionFactory sessionFactory
Configuring Hibernate
Configuring Hibernate  How to configure Hibernate?   ... by the Configuration class to create the SessionFactory which in turn creates...; <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate
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
DataSource in hibernate.
DataSource in hibernate.  What is DataSource in hibernate?   Generally, in spring hibernate integration or struts hibernate integration we set data source class for integration. Here is a example of spring hibernate
in connectivity - Hibernate
hibernate for use SessionFactory sessionFactory = new Configuration... the hibernate and postgresql that progrram is running while showing no error... insertted  Hi friend, This is connectivity and hibernate configuration
hibernate firstExample not inserting data - Hibernate
//and prepare hibernate for use SessionFactory sessionFactory...hibernate firstExample not inserting data  hello all , i followed... for more information. http://www.roseindia.net/hibernate/ Thanks. 
Persist a List Object in Hibernate - Hibernate
on hibernate. How to persist a List object in Hibernate ? Can you give me...{ SessionFactory sfact = new Configuration().configure().buildSessionFactory.... http://www.roseindia.net/hibernate/projections/hibernate-projections.shtml
Searching - Hibernate
Searching  How we can search the record through Hibernate. As we do rs.next() to get the records in jdbc .Then how we can do this using Hibernate...{ SessionFactory sessionFactory = new Configuration().configure
Hibernate - Framework
) { SessionFactory sessFact=null; Session sess=null; try { sessFact=new... on hibenate to visit.... http://www.roseindia.net/hibernate/index.shtml Thanks
Define the session factory interface in hibernate?
Define the session factory interface in hibernate?  Define the session factory interface in hibernate?   Session factory is used for manageing the session objects.public interface SessionFactory extends Referenceable
hibernate update problem
hibernate update problem  HI, I integrated the struts and hibernate and wrote the following query in the databean to update the user table login time SessionFactory sessionFactory = (SessionFactory)context.getAttribute
Hibernate Architecture
) that will be instantiated by created by Hibernate, an instance of SessionFactory...Hibernate Architecture In this tutorial you will learn about the Hibernate architecture. Here we will understand about the architecture of Hibernate using
Hibernate API
Hibernate API In this section we will learn about important Hibernate API. Hibernate one of the best ORM tool to develop database driven applications in Java. Hibernate provides API to perform CRUD operations on the persistence objects
struts - hibernate doubt
struts - hibernate doubt  Hello. I'm developing a web application using Struts 1.0 and Hibernate (I'm a beginner). I've been reading your web and I've seen that in the Struts Action methods you use an Hibernate Plugin
Using sum() in hibernate criteria.
Using sum() in hibernate criteria.  How to calculate sum() in hibernate criteria by using projection?   You can calculate sum of any numeric value in hibernate criteria by using projection. Projection is an interface
Hibernate criteria count.
Hibernate criteria count.  How do we count rows using criteria in hibernate?   Create hibernate configuration file (hibernate.cfg.xml... create Persistent class ?Hibernate uses the Plain Old Java Object (POJO) classes
Hibernate delete a row error - Hibernate
Hibernate delete a row error  Hello, I been try with the hibernate delete example (http://www.roseindia.net/hibernate/hibernate-delete.shtml... { SessionFactory fact = new Configuration().configure().buildSessionFactory
Problem in running first hibernate program.... - Hibernate
and prepare hibernate for use SessionFactory sessionFactory = new Configuration... hibernate.cfg.xml and prepare hibernate for use SessionFactory sessionFactory = new...Problem in running first hibernate program....  Hi...I am using
Hibernate Interceptor
Hibernate Interceptor In this tutorial you will learn about Hibernate... a configured and registered events or actions. In Hibernate an interface... session. SessionFactory-scoped Interceptor : This interceptor is specified
Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row... void main(String []args){ SessionFactory sessionFactory
Hibernate Transaction
Hibernate Transaction In this tutorial you will learn about the Transaction in Hibernate. In transaction multiple operations are gathered into a single unit of work. On failure of operation in the batch Hibernate throws exceptions, any
Hibernate criteria for date.
Hibernate criteria for date. In this example, you will see how to create... List<StudentModel> resultData(StudentModel obModel) { SessionFactory sessionFactory = new AnnotationConfiguration() .configure
Hibernate criteria restrictions.or
Hibernate criteria restrictions.or In this tutorial, you will see the use...;StudentModel> resultData(StudentModel obModel) { SessionFactory sessionFactory = new AnnotationConfiguration() .configure
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate?   Here is an example - package...){ SessionFactory sessionFactory=HibernateUtil.getSessionFactory
Hibernate case sensitive comparison.
Hibernate case sensitive comparison.  How to check for case sensitive in Hibernate criteria?   package net.roseindia.main; import...){ SessionFactory sessionFactory = ConnectionUtil.getSessionFactory
Hibernate criteria conjunction..
Hibernate criteria conjunction..  What is criteria conjunction in Hibernate?    In Hibernate, Criteria Conjunction works as logical... of bellow example- Steps- 1.Copy library (jar file) of hibernate into your lib folder
Complete Hibernate 4.0 Tutorial
Hibernate Configuration File Hibernate SessionFactory Example First Hibernate...Complete Hibernate 4.0 Tutorial Hibernate is a Object-relational mapping (ORM... data types. Hibernate is a persistence framework which used to store and fetch
Hibernate Basic Example not working
Hibernate Basic Example not working  I have implemented basic hibernate example from your site . In console i got output but database is not affected...{ SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory
Hibernate criteria query using Max()
Hibernate criteria query using Max()  What is Hibernate criteria query using Max()?   You can find out maximum value in hibernate criteria...) { SessionFactory sessionFactory = HibernateUtil.getSessionFactory
Hibernate criteria query using Min().
Hibernate criteria query using Min().  How to find minimum value in Hibernate criteria query using Projection?   You can find out minimum value in hibernate criteria by using projection. Projection is an interface
Hibernate criteria query using avg()
Hibernate criteria query using avg()  How to calculate average in Hibernate criteria query using Projection?   You can calculate average of any numeric values in hibernate criteria by using projection. Projection
Hibernate criteria restrictions.in
Hibernate criteria restrictions.in In this example, you will see the use of Restrictions class in java. It is used to restrict the retrieval of data from...) { SessionFactory sessionFactory = new AnnotationConfiguration