Home Tutorialhelp Comment after modifying works fine,change FirstExample

 
 

Comment

toto
after modifying works fine,change FirstExample ,
August 4, 2010 at 5:36 PM

package com.jsfvalidation.hibernatefactory;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

import com.jsfvalidation.hibernate.beans.Contact;

public class FirstExample {
public static void main(String[] args) {
Session session = null;

try {
// This step will read hibernate.cfg.xml
// and prepare hibernate for use
SessionFactory sessionFactory = new Configuration().configure()
.buildSessionFactory();
session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
// Create new instance of Contact and set
// values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_38@yahoo.com");
session.save(contact);
tx.commit();
System.out.println("Done");
} catch (Exception e) {
System.out.println(e.getMessage());
} finally {
// Actual contact insertion will happen at this step
session.flush();
session.close();

}

}
}
View All Comments | View Tutorial
Related Tutorial and Articles
Hibernate Questions

hibernate firstExample not inserting data - Hibernate
hibernate firstExample not inserting data  hello all , i followed... for more information. http://www.roseindia.net/hibernate/ Thanks. ... is : my FirstExample is : /** * */ package 

Hibernate Questions

hibernate firstexample - Hibernate
hibernate firstexample  Hi all. i m new with hibernate,when i m trying to run my first application i m getting following exception. Error reading resource: Employee.hbm.xml give me the solution. Thank you 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  firstExample code that you have given for hibernate... inserted in the database from this file. http://www.roseindia.net/hibernate/runninge-xample.shtml Thanks 

Hibernate Questions

hibernate
hibernate  how to impot mysql database client jar file into eclipse for hibernate configuration   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate/runninge-xample.shtml Thanks 

Framework Questions

Frame works - Framework
Frame works  I need tutorials on JAVA Plugin Frameworks and hibernate and springs ? I new to these Technologies so i need with Examples to understand Using above technologies i need to do project. so ASAP pls 

Hibernate Interview Questions

Hibernate:What is hibernate?
. Hibernate works as a bridge between application and database. Application... mismatch problems. Hibernate works as a bridge between application and database...Hibernate:What is hibernate?  What is hibernate?    

Hibernate Questions

Problem in running first hibernate program.... - Hibernate
/FirstExample Exception in thread "main" " http://www.roseindia.net/hibernate/runninge...Problem in running first hibernate program....  Hi...I am using... programs.It worked fine.To run a hibernate sample program,I followed the tutorial below 

PHP Tutorial

Modifying the Path Example.
Modifying the Path In this example, you will learn how to modify the corrupted path using $outpath command in PHP. This command will modify the path... and if it finds it during compilation. After detecting the correct path 

XML Tutorials

Modifying Text by Cutting and Pasting
Modifying Text by Cutting and Pasting     ... after cutting is: " + name.getData());  ...; name.appendData(bridge);   System.out.println("name after pasting 

XML Tutorials

Modifying Text by Replacement
Modifying Text by Replacement       This Example describes a method to modify the Text in a DOM... Replacement is: Roseindia.net Text after Replacement is: Girish Tewari 

Hibernate-Tutorials

Hibernate : getCurrentSession()
This tutorial describes how getCurrentSession() method works in Hibernate 

Hibernate-Tutorials

Hibernate save()
This tutorial explain how save() works in hibernate 

Hibernate Questions

What is hibernate ?
problems. Hibernate works as a bridge between application and database...What is hibernate ?   What is hibernate ? explain with simple example.   Hibernate is an Open Source persistence technology. It provides 

Hibernate-Tutorials

Hibernate : Session Lock
This tutorial contains how Session.lock() method works in Hibernate 

Hibernate-Tutorials

Hibernate : Session Save
In this section we will discuss how session.save() works in Hibernate 

Hibernate-Tutorials

Hibernate : Dynamic-update
In this section we will discuss how dynamicUpdate works in Hibernate 

Hibernate-Tutorials

Hibernate Prepared Statement
This section contain how prepared statement works in hibernate 

Hibernate Questions

Hibernate application - Hibernate
Hibernate application  Hi, Could you please tell me how to implement hibernate application in eclipse3.3.0 Thanks, Kalaga.  Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate 

Java Beginners

calculation after if. user input
calculation after if. user input  System.out.print ("please select one of the following by pressing tne number on your keypad"); System.out.println... of the following items (i have to pick 3 items so have the below done 3 times it works I am 

Programming Tutorials

HIBERNATE IN CONSOLE & SERVLET
HIBERNATE IN CONSOLE & SERVLET ( part-3...; In this continuation of the earlier tutorial on Hibernate( July-2005) , the author gives a demo for using Hibernate in a console application & a servlet.  

Hibernate Questions

hibernate web project - Hibernate
links: http://www.roseindia.net/hibernate/index.shtml http://www.roseindia.net/hibernate/runninge-xample.shtml http://www.roseindia.net/struts/struts...hibernate web project  hi friends,very good morning,how to develop 

Java Beginners

how to make this java mail works? - Java Beginners
how to make this java mail works?  Dear experts, Recently, I borrowed a book by William Broden and managed to get the source codes from the author... don't have a clue how to make this file work at all, even after reading 

Hibernate Questions

java - Hibernate
/hibernate/runninge-xample.shtml Thanks...java  HI guys can any one tell me,procedure for executing spring and hibernate in myeclipse ide,plz very urgent for me,thank's in advance.   

JSP Servlet Questions

Modifying a single row of database based on selection in jsp
Modifying a single row of database based on selection in jsp  Hi guys, i have a problem, I am Fetching the results from database and displaying in a row with s3everal columns, each row having a radio button and a value 

Hibernate Questions

hibernate Configuration with eclpse 3.1 - Hibernate
/hibernate/runninge-xample.shtml http://www.roseindia.net...hibernate Configuration with eclpse 3.1  Dear Sir, i m developing a program using hibernate with struts. but i am not able to configure 

Hibernate-Tutorials

Hibernate : Stateless Session
In this section we will show how stateless session works 

Programming Tutorials

VoIP Works
VoIP Works How VoIP Works If you've never heard of VoIP, get ready to change the way you think about long-distance phone calls. VoIP...;   How VoIP Works-Busting Out of Long Distance Rates 

Struts Examples

How Struts Works
How Struts Works       The basic purpose of the Java Servlets in struts is to handle requests... : This is the second step performed by the container after checking the web.xml file 

Hibernate-Tutorials

Hibernate Event System
Hibernate Event System In this tutorial you will learn about the Event system in Hibernate. As concerned to Event it can be said that Event has replace... pre-requisite or post-requisite operations before or after the functional logic 

Hibernate Questions

Java - Hibernate
, this type of output. ---------------------------- Inserting Record Done Hibernate... FirstExample { public static void main(String[] args) { Session session = null... = null; try{ // This step will read hibernate.cfg.xml and prepare hibernate 

Hibernate Questions

Reg Hibernate - Hibernate
Reg Hibernate  Hi, iam using hibernate in myeclipse ide. I got an error. After doing reverse-engineering my table user, i opened HQL editor and written query as from user. I am getting this error 

Hibernate Questions

Hibernate one-to-many relationships.
Hibernate one-to-many relationships.  How does one-to-many relationships works in hibernate 

Hibernate Questions

Could not read mappings from resource: e1.hbm.xml - Hibernate
/*tHIS IS THE HIBERNATE cONFIGURATION*/ /*THIS IS THE HIBERNATE... org.hibernate.cfg.Configuration; import org.hibernate.cfg.*; public class FirstExample 

Hibernate Questions

java(Hibernate) - Hibernate
java(Hibernate)  Hai Amardeep This is jagadhish.Iam giving full code...(); Transaction tx=session.beginTransaction(); System.out.println("After Tx...); System.out.println("After s.add(ph1)."); user.setPhoneNumbers(s 

Spring Framework

How Spring MVC Module Works
How Spring MVC Works      How Spring MVC Works? In this we will see the request flow for the spring framework... to this Servlet. It works as the front controller and handle all 

Hibernate Questions

Hibernate HQL query by using like operator.
Hibernate HQL query by using like operator.  How use like operator in HQL?   HQL stands for Hibernate Query Language, provided by Hibernate. It is minimal object oriented, similar to SQL.It works like a bridge between 

Struts Questions

Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after... from database on to the JSP page when it initially loads. After Submitting 

Struts Questions

Struts2 and Hibernate
Struts2 and Hibernate   I have a simple application in Struts2 and Hibernate which have simple form for entering contact information and after... database on to the JSP page when it initially loads. After Submitting it data 

Java Beginners

How TCP/IP works ?
How TCP/IP works ?  hello,, Can some body tell me how TCP/IP works?   hii, TCP/IP is just a protocol that allows different nodes on the network/Internet to share resources and without TRANSMISSION CONTROL PROTOCOL 

Swing AWT

Run time Exception after Clean and Build JavaNetBeans Project
Splash From) Opens fine but after progress bar is filled it should be disappeared... opens.. But It works fine when i run project from NetBeans and all forms opens...Run time Exception after Clean and Build JavaNetBeans Project  I have 

Hibernate Questions

Hibernate Training
Hibernate Training  What is the time duration for this training? Am I going to get some certificate after this training? How much is the fees for this? What will be the method - desktop sharing or con call or you will just 

Hibernate Questions

jeetendradash - Hibernate
jeetendradash   how this code works?i just want to know when we execute session.getNamedQuery("Insname"), what happens? how the above code invoked? can anyone explain please?thnx 

JSP Servlet Questions

Works only for one row
Works only for one row   Hi, My below code is working only if there is a single row. could you please help me in doing it for all the rows retrieved from the database. <%@page import="java.util.concurrent.CountDownLatch 

Hibernate Questions

Ask for latest version for hibernate
Ask for latest version for hibernate  any new version for hibernate after 3.0, if yes can u give some exmp for latest version of hibernate 

JSP Servlet Questions

Code Works - JSP-Servlet
Code Works  Hi The code provided is working fine along with the pagination . i edited the queries and that makes difference.. here is the code. Thank you Regards Eswaramoorthy Pagination of JSP page 

Struts-Tutorials

Struts 2, JPA and Hibernate Training
Struts 2, JPA and Hibernate Training       The Struts 2, JPA and Hibernate Training for developing enterprise applications with Struts 2 framework. Course Code: STRUS-2/JPA/Hibernate Duration 

Blog

Sitemap Hibernate Tutorial
; Tutorial Section Introduction to Hibernate 3.0 | Hibernate Architecture | First Hibernate Application | Running the Example in Eclipse | Understanding Hibernate O/R Mapping | Understanding Hibernate <generator> element 

Hibernate Tutorial Example

Hibernate 3 Query Example Part 1
Hibernate 3 Query Example Part 1       Hibernate 3 Query Example Part 1 Hibernate 3 well works with Spring framework. You can use Hibernate and Spring 3 for making 

Hibernate-Tutorials

Hibernate and Spring
Hibernate and Spring In this section we will discuss Hibernate and Spring... business. Hibernate and Spring are excellent technologies and can be used.... In this page you will find excellent tutorial links for integrating Hibernate 

Java Beginners

Works when run from desktop but....
Works when run from desktop but....  I used the code provided here for a pie chart using swing in Java, and when I saved it to my desktop, it ran fine, and worked as explained, but then I tried to add the same code to NetBeans 

Hibernate-Tutorials

Hibernate advantages and disadvantages
Framework: There are many caching framework that works with Hibernate. You can...Hibernate advantages and disadvantages In this section we will discuss Hibernate advantages and disadvantages, and see why we should or shouldn't use 

Programming Tutorials

HIBERNATE- BASICS
HIBERNATE- BASICS  (R.S.Ramaswamy)- ( in 3 parts) (part-1) ( CMP-EJB vs. HIBERNATE) (published in DeveloperIQ-July-2005... is agog with excitement about a very popular open-source technology , Hibernate 

Hibernate-Tutorials

Complete Hibernate 4.0 Tutorial
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... to any time which may be after ending the process which stores data 

General Information

How does GPS Tracking Devices Works for Automobiles?
of GPS and after that the updates of the location are transmitted at a regular interval of time or after any change in the event, e.g. ignition on / off. Earlier... the software for GPS tracking with the internet to view the location. After 

Framework Questions

struts and hibernate integration
struts and hibernate integration  i want entire for this application using struts and hibernate integration here we have to use 4 tables i.e... login and select the courses using chekboxes and logout after that admin login 

Hibernate Questions

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 

Hibernate Interview Questions

HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate 

Hibernate Interview Questions

hibernate
hibernate  what is hibernate flow 

Hibernate Questions

hibernate
hibernate  what is hibernate listeners 

Hibernate Questions

Hibernate session.refresh() method
Hibernate session.refresh() method  What is session.refresh() in hibernate?   It is possible to re-load an object and all its collections... (after the trigger executes 

Hibernate Interview Questions

Explain the persistence class in hibernate?
Explain the persistence class in hibernate?  What is persistence class in hibernate?   Persistence class are simple POJO classes in an application. It works as implementation of the business application for example 

Hibernate Tutorial Example

Hibernate criteria restrictions.or
Hibernate criteria restrictions.or In this tutorial, you will see the use of or constraints of Restricatrions class in java. It is available...),Restrictions(propertyName, propertyValue)); The or constraints works as logical 

Java Beginners

hibernate
hibernate  how to uses optional column in hibernate 

Hibernate Questions

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 Questions

Hibernate
Hibernate  hibernate delete query execution 

Hibernate Questions

hibernate
hibernate  what is hibernate why we use 

Hibernate Questions

Hibernate
Hibernate  how to use pagination concept in Hibernate 

Hibernate Interview Questions

.When to use detached criteria in hibernate?
.When to use detached criteria in hibernate?  When to use detached criteria in hibernate?   Detached Criteria query is a facility provide by Hibernate to write criteria queries in detached mode, where hibernate session 

Hibernate Questions

hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application 

Hibernate Questions

hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application 

Hibernate Questions

email confirmation - Hibernate
email link after that I should read user data from hibernate/MySql and make some... about integration of Hibernate and JSF and Spring, and I need to add some more... the same user) After I would do: dao.updateUser(usr); Thanks  I 

Hibernate Questions

java compilation error - Hibernate
whosevalues should be inserted into database. i have used hibernate and eclipse it is working fine. but when i make a war file and deploy it using ant and then run...).By that only this exeptions rise dude..Try it and give your result after 

Hibernate Interview Questions

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..., Serializable.It is in org.hibernate.SessionFactory. It works as a factory 

Hibernate Questions

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 

Java Beginners

hibernate
hibernate  pls give one simple example program for hibernate 

Hibernate Questions

hibernate
hibernate  why we should use hibernate projection 

Hibernate Questions

Hibernate
Hibernate  Please tell me the difference between hibernate and jdbc 

Hibernate Questions

composinte primary key in hibernate
. After doing hibernate reverse engineering, by default it has taken composite primary key with all the columns of the table and hibernate s/w has created two pojo 

Hibernate Questions

Hibernate
Hibernate  hello, how to run hibernate program in netbeans?please send me step by step instructions to run hibernate in netbeans 

Hibernate Questions

hibernate
hibernate  can any one one explain what is hibernate ?   Please visit the following link: Hibernate Tutorials 

Hibernate Questions

hibernate
hibernate  how to execute a sequence(in database) from Hibernate program or java program   Please visit the following link: Hibernate Tutorials 

Hibernate Interview Questions

Hibernate
Hibernate  How do you handle parent - child tables relationships in hibernate? How do you handle Detach state in hibernate 

JavaMail Questions

result after compilation
result after compilation  public class MainCls { public static void main(String argv) { System.out.println("My text 

Technology

Role of maps and compass after GPS
Role of maps and compass after GPS       Maps and compass are two of the most essential equipments... of navigation and works with the help of these two equipments. Maps 

Hibernate Questions

Hibernate - Hibernate
Hibernate Features  Hibernate features in eclipse 

Hibernate Questions

Hibernate
Hibernate  hi sir i need hibernate complete tutorial for download   Hi Friend, Please visit the following link: Hibernate Tutorials Thanks 

SQL Question

trigger after insert for deletion
trigger after insert for deletion   String query2 = "create TRIGGER trig after insert on "cart" + " FOR EACH ROW " + " BEGIN " + " declare expiry1 date 

JSP Servlet Questions

Why disable.this works in fireFox but n ot IE
Why disable.this works in fireFox but n ot IE  When I put this line of code in my program, it works beautifully in firefox, but does not submit when using IE <input type="submit" id="9" value="Generate Report" onclick 

Hibernate Questions

hibernate
hibernate  How to know how many columns changed in a table when we are using hibernate 

Hibernate Questions

hibernate
hibernate  hi what are the necessary jar files that we need to set in the classpath to execute a hibernate application 

Hibernate Interview Questions

HIBERNATE
HIBERNATE  How u connects database using hibernate 3.0? Where you have written the database configuration details 

Hibernate-Tutorials

Hibernate Interceptor
Hibernate Interceptor In this tutorial you will learn about Hibernate... or after the core functional logic, these events can be a set of pre-requisite... a configured and registered events or actions. In Hibernate an interface 

Java Beginners

Update after delete
Update after delete  sir,i am working on online examination project in servlet.I am facing some problem that are -i have assign id column 1,2,3..... and i am deleting 3 record using id column of database mysql so now id 

Hibernate Tutorial Example

Hibernate Tools Update Site
the confirmation message and then ask for restart. After restart Hibernate tools... Hibernate Tools Update Site       Hibernate Tools Update Site In this section we 

Hibernate Questions

hibernate
hibernate   i am using hibernate3.2.5 and oracle9i. First i set classpath to ojdbc14.jar and all the hibernate jar files to path env variable.After that when i try to execute the program i got an error "unknown oracle major 

Hibernate Questions

hibernate
hibernate  Is there any other way to call procedure in hibernate other than named query????? if we are using session object to get the connection then why hibernate we can directly call by using a simple java class??????? please 

Hibernate Questions

Your hibernet tutorial is not working - Hibernate
Your hibernet tutorial is not working  Hi, I am learning hibernate from your tutorial. when i execute the 1st hibernate example at following location http://www.roseindia.net/hibernate/firstexample.shtml it working 

Hibernate Questions

hibernate
hibernate  when we using schemaExport in hibernate every time it drops the existing table and create new table ,if table contain dependent table then is it drop 

Hibernate Questions

Hibernate
of Hibernate. I followed all th steps as given in the tutorial, but a build error... hibernate library files are not included in the project build path. Please download the example from Hibernate Getting Started Tutorial. Please follow the steps 

Hibernate Tutorial Example

Hibernate Mapping Files
Hibernate Mapping Files       Hibernate Mapping Files: In this section I will describe you the necessary Hibernate Mapping Files that is required 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.