Comment

Victor Aguilera
Right code,
June 14, 2010 at 11:04 PM

here is the code that works!

public static void main(String[] args) {
// TODO code application logic here

Session session = null;

try{
// This step will read hibernate.cfg.xml

System.out.println("creating session factory");

SessionFactory sessionFactory = new Configuration().
configure(new File("D:\\NetBeansProjects\\Hibernate\\src\\hibernate\\hibernate.cfg.xml"))
.buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set


System.out.println("Inserting Record");
User contact = new User();

contact.setEmailAddress("vic@vic.com");
contact.setLastLogon(new Date());
contact.setPassword("pass");
contact.setUserID("n2342");
contact.setUserName("Victor");

Transaction tx=session.beginTransaction();

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
Advertisement
Related Tutorial and Articles
Hibernate Questions

hibernate firstExample not inserting data - Hibernate
hibernate firstExample not inserting data  hello all , i followed... in the firstExample as below. I will later post the actual code issue later. here i am....  Hi friend, Please send me code and explain in detail. Visit 

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 to insert the record in contact table,that is not happening neither it is giving... inserted in the database from this file. http://www.roseindia.net/hibernate 

Hibernate Interview Questions

Hibernate Code - Hibernate Interview Questions
Hibernate Code   Hi Friends, In Hibernate, wat is Annotation. There is no need of hibernate configuration file in hibernate version 3 - right . but hbm is necessary for all versions 

Hibernate-Tutorials

Hibernate Right Outer Join
In this section, you will learn how to do Right Outer Join in Hibernate 

HTML Questions

div style float right
div style float right  How to align div to right? Share me the code for div style float right. Thanks   Hi, You can use following code: <div style="float: right; widht:300px; height:600px;"> <p>Content< 

Java Beginners

Am i convetrting the code right ? - Java Beginners
Am i convetrting the code right ?  C# private void button... (IOException ex) { }// i also tried the code below// try... a led on it. The LED blinks on the C#'s code. I think the code i have written 

Java Beginners

Hibernate code
Hibernate code  programm 4 hibernate  Hi, Read hibernate tutorial at http://www.roseindia.net/hibernate/ Thanks   please read at the the link http://www.roseindia.net/hibernate 

Hibernate Questions

hibernate code - Hibernate
hibernate code  while generating the hibernate code i got the error like org.hibernate.MappingException 

Hibernate Questions

Hibernate Code - Hibernate
Hibernate Code   How to Invoke Stored Procedure in Hibernate???????? Plz provide details code 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  how to write hibernate Left outer join program 

Hibernate Questions

hibernate code - Hibernate
hibernate code  How to store a image in mysql or oracle db using struts &hibernate 

Hibernate Questions

HIBERNATE CODE - Hibernate
HIBERNATE CODE  Dear sir, I am working with MyEclipse IDE.I want to connect with MYSQL using Hibernate. What is the Driver Template and URL of MYSQL toconnect using Hibernate 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  can you show the insert example of Hibernate other than session.save(obj);  Hi I am sending a link where u can find lots of example related to hibernate... http://www.roseindia.net/hibernate 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   I am facing a problem in hibernate program. Error is ::: Error in reading contact.hbm.xml contact.hbm.xml is my hibernate mapping file.  Hi Friend, check whether you have specified correct path 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   how to write hql query for retriveing data from multiple tables 

PHP

PHP SQL Right Join
PHP SQL Right Join  This Example illustrates how to use right join clause in the sql query. The right join return all rows from the right table, even if there are no matches in the left table. In this example right join is used 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem   Hi This is Raju I tried the first example of hibernate course material.This is to insert a record into CONTACT table.Is Hibernate code automatically creates the CONTACT table and then insert 

Java Tips and Examples

Unsigned right shift ">>>" Operator
of code: The unsigned right shift ">>>"operator shifts a zero... Unsigned right shift ">>>" Operator   ... unsigned right shift ">>>"operator in Java. The Java programming language has 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   example code of how insert data in the parent table and child tabel coloums at a time in hibernate  Hi friend, I am...: http://www.roseindia.net/hibernate/insert-data-database.shtml Thanks 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... in the DAO.Can it be possibe. Please send some sample code.. thanks... to : http://www.roseindia.net/hibernate/index.shtml Thanks 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code   Hi How to intract struts , spring and Hibernet. Explain architecture flow.   Hi Friend, Please visit the following link: http://www.roseindia.net/struts/hibernate-spring/index.shtml Here 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hi This is Raju.I tried the first example of Hibernate material what u have given. I have written contact.java... session.flush(); i am using hibernate 3.3.1 and I kept hibernate3.jar 

Hibernate Questions

hibernate code problem - Hibernate
hibernate code problem  suppose i want to fetch a row from the table... . Please visit for more information. http://www.roseindia.net/hibernate/selectclause.shtml If you have any problem this send me detail and source code 

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

hibernate code - Hibernate
hibernate code  sir, i have tried ur hibernate 3.0 firt example code, i have done as u have told in the tutorial like import all the related jar files,made asimple java project and copied the two xml files into src/bin 

Hibernate Questions

hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance...: " + insurance. getInsuranceName()); } in the above code,the hibernate... thanks shakti  Hi friend, Your code is : String SQL_QUERY =" from 

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 

Hibernate Questions

hibernate code - Hibernate
hibernate code  well deepak,Regarding the inputs u asked for my fisr question, i have downloaded the complete project from the roseindia site...{ // This step will read hibernate.cfg.xml and prepare hibernate for use SessionFactory 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hai, iam working on simple login application using hibernate in spring. I've used Spring dependency injection too.I.... Please find my src code here... ----------------controller Layer 

SQL Tutorial

PHP SQL Right Join
PHP SQL Right Join       This Example illustrates how to use right join clause in the sql query.  JOIN is used to query data from two or more tables. The right 

General

Java Right Shift ">>" Operator
the usage of  right shift ">>"operator. Description of code... the code of right shift operator.  Here is the code of program: ... Java Right Shift ">>" Operator   

Java Beginners

TRIANGLE OF *S AT THE BOTTOM RIGHT!!! - Java Beginners
TRIANGLE OF *S AT THE BOTTOM RIGHT!!!  My Question is to : "Write... with the right angle at the bottom-right." PROBLEM: Have tried so many times to make the triangle at the right side but couldn't do so. Can you please solve 

Servlets

Natural Right Join
Natural Right Join      ... will be natural right join.  To join the tables firstly it is important to make... are using the MySql database. To join the table in a natural right join manner 

Hibernate Interview Questions

Hibernate Code - Hibernate Interview Questions
Hibernate Code  This is the question asked in CAPEGEMINI Write a sample code how to persist inner class,interface,final class and how to invoke stored procedure in hibernate? From Surjeet 

Hibernate Questions

Compilation error. Hibernate code - Hibernate
Compilation error. Hibernate code   Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory at org.hibernate.cfg.Configuration.(Configuration.java:152) at com.sat.Manager.main(Manager.java:10 

JSP Servlet Questions

Reversing dojo slider to make it slide from right to left rather left to right as given
Reversing dojo slider to make it slide from right to left rather left to right... the slider chosen value so that it slides from right to left ie the blueish part on slider must start from right side of the slider so that slider slides from 

JDBC

Join tables with the NATURAL RIGHT JOIN operation
table (Emp_sal). Description of code: SELECT *FROM employee NATURAL RIGHT JOIN... Join tables with the NATURAL RIGHT JOIN operation... the NATURAL RIGHT JOIN operation of table in a specific database. This operation join 

Hibernate Questions

myfaces,hibernate and spring integration - Hibernate
myfaces,hibernate and spring integration  sorry, in the previous qurey i have mentioned the Wrong URL.the right url is: http://www.roseindia.net/jsf/myfacesspring/downloadcode.shtml the code given in this url : http 

Hibernate Questions

Hibernate 4.3 JPA 2.1
the integrated code to use Hibernate 4.3 through JPA 2.1 in my application. Thanks in advance.   Yes you are right the latest version of Hibernate...Hibernate 4.3 JPA 2.1  How to create a Java program using Hibernate 

Hibernate Questions

Hibernate - Hibernate
Hibernate  What is a lazy loading in hibernate?i want one example of source code?plz reply 

Hibernate Questions

hibernate - Hibernate
hibernate  what is hibernate and how to make a pc hibernating?  Hi friend, Hibernate is based on object oriented concept like java... .properties file and in hibernate we use .xml file ,which is a better approach. We 

Hibernate Interview Questions

Hibernate sample code - Hibernate Interview Questions
Hibernet.org.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines...Hibernate sample code  Hi Can any body tell me how to persist inner class,abstract class,final class,and interface in hibernate. From 

Hibernate Questions

Hibernate Criteria Transformer Example code
Hibernate Criteria Transformer Example code  Hello, I am trying to find the example of Hibernate Criteria Transformer. Tell me the good tutorial of Hibernate Criteria Transformer with source code. Thanks   Hi, Check 

Hibernate Questions

Hibernate - Hibernate
Hibernate  when I run Hibernate Code Generation wizard in eclipse I'm getting the following error. I added ojdbc14.jar to my build path. Still I'm.../hibernate/index.shtml Hope that it will be helpful for you. Thanks 

Hibernate Questions

Hibernate - Hibernate
Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import... { } }}--------------------------  This is mapping code,<?xml version=" 

JSP Servlet Questions

how to set the tables one is left and another one is right - JSP-Servlet
how to set the tables one is left and another one is right  Here two tables are combined.i need to set the one table is left another one is right...(table); document.close();   Hi Friend, Try the following code 

Java-Tutorials

Joining two tables using Natural right join
Join Table with Natural Right join In Natural Right join, both table... to the Second table's field values  means a Right join returns all the values from the right table and matched values from the left table (NULL in case 

Hibernate-Tutorials

Complete Hibernate 4.0 Tutorial
Hibernate Right Outer Join Hibernate Criteria... hibernate by example hibernate repository hibernate sample code... This section contains the Complete Hibernate 4.0 Tutorial 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai this is jagadhish while running a Hibernate.../hibernate/ Please specify your requirements in detail. It would be good for me to provide you the solution if problem is clear. please post all code 

Hibernate Questions

hibernet code - Hibernate
 

Hibernate Questions

myJSF,Hibernate and Spring integration code is not working. - Hibernate
myJSF,Hibernate and Spring integration code is not working.  the code given in this url : http://www.roseindia.net/roseindiamembers/login.php i have tried but it does not work. when i write http://localhost 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

this is a hibernate question
this is a hibernate question  connection pooling code in hibernate 

Hibernate Questions

Hibernate 1 - Hibernate
Hibernate 1  what is a fetchi loading in hibernate?i want source code?plz reply 

Hibernate Questions

Java Compilation error. Hibernate code problem. Struts first example - Hibernate
Java Compilation error. Hibernate code problem. Struts first example  Java Compilation error. Hibernate code problem. Struts first example 

Hibernate Questions

Hibernate Criteria Query Example with source code
good example of Hibernate Criteria Query Example with source code? Thanks   Here is good Example program of Hibernate Criteria Query with source code. The source code of the Hibernate Criteria Query will help you in grasping 

Hibernate Questions

Hibernate tutorial - Hibernate
Hibernate tutorial  can u provide me some material in hibernate.  Hello Rohin,You can learn Hibernate within 10 days from our website. In our hibernate tutorial you will find many examples with running code. You can 

Hibernate Questions

HIbernate call for sequence - Hibernate
HIbernate call for sequence  I have created a sequence in oracle table. Now how to access this in java class through hibernate from dual table i am..._S is this the right way to retrive the next value from 

Hibernate Questions

Hibernate Annotattions - Hibernate
Hibernate Annotattions  Can anybody tell me here how we can use hibernate annotations which is a new facility in hibernate 3.2 any tutorial and what.... The Hibernate Annotations is the powerful way to provide the metadata for the Object 

Hibernate Interview Questions

Hibernate:What is Hibernate proxy?
is created by default by Hibernate, for mapping a class to a file. The code to invoke...Hibernate:What is Hibernate proxy?  What is Hibernate proxy?   Proxy means the authority to represent someone else In hibernate, you can 

Hibernate-Tutorials

hibernate sample code
This section contains a simple Hibernate 4 example using Annotation with source code. The eclipse id and Apache Tomcat is used in this example 

Hibernate Questions

j2eee(Hibernate) - Hibernate
j2eee(Hibernate)  Hi, This is jagadhish.Iam learning Hibernate.I... relations in Hibernate(with examples).But not showing the link available... any problem. Please specify in detail and send me code. I am sending you 

Hibernate Questions

Need for hibernate - Hibernate
Need for hibernate  Can anyone say why should we go for hibernate?   Hi friend, Advantages of hibernate : It is based on object... solution. In Jdbc we use .properties file and in hibernate we use .xml file 

Hibernate Questions

Hibernate- Oracle connection - Hibernate
Hibernate- Oracle connection  In Eclipse I tried Windows --> Open perspective--> other in that Database Development Right click on databaseconnection --> New Oracle Added ojdbc14 Jar file path UID 

Hibernate Questions

Struts-Hibernate-Integration - Hibernate
Struts-Hibernate-Integration  Hi, I was executing struts hibernate intgeration code the following error has occured. Anyone can give me... the following link: http://www.roseindia.net/struts/struts-hibernate/ Hope 

HTML Questions

align a table to the right (or left).
align a table to the right (or left).  How do I align a table to the right (or left 

HTML Questions

align a table to the right (or left).
align a table to the right (or left).  How do I align a table to the right (or left 

Hibernate Interview Questions

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 Questions

C3P0 with Hibernate
C3P0 with Hibernate  How to use C3PO with Hibernate? Thanks   Hi, Please check the tutorial C3P0 Hibernate. In this page we have source code example of using C3P0 with Hibernate. Thanks 

Hibernate Questions

Data fetch from multiple SQL tables - Hibernate
my first hibernate application. I have a sql query that fetches data from multiple tables using left and right outer joins. I need to convert this JDBC data access code into Hibernate code. The tables in SQL are not related using foreign 

Java Beginners

right and left shift operators
right and left shift operators   hi i am jane pls explain the differentiate between right shift and left shift operators  ... by the number of bits specified by its right operand. While the right shift "> 

Hibernate Questions

Could not read mappings from resource: e1.hbm.xml - Hibernate
code, hibernate mapping was not correct. i am sending hibernate mapping code... /*tHIS IS THE HIBERNATE cONFIGURATION*/ /*THIS IS THE HIBERNATE 

Hibernate-Tutorials

hibernate by example
In this tutorial you will learn hibernate by example with ready made downloadable source code 

Hibernate Tutorial Example

Hibernate
. We have tried to provide many articles, examples and code at our Hibernate 4...Hibernate Hibernate is a framework for Java technology, which is used.... Hibernate is Java library which is used to develop the data access layer 

Quartz Tutorials

SQL Right JOIN
SQL Right JOIN       The RIGHT JOIN keyword returns you  all rows from the right table (table_name1), incase if there are no matches in the left table 

Hibernate Questions

java(Hibernate) - Hibernate
java(Hibernate)  Hai Amardeep This is jagadhish.Iam giving full code... will read hibernate.cfg.xml and prepare hibernate for use SessionFactory... for more information. http://www.roseindia.net/hibernate/ Thanks Amardeep 

Hibernate-Tutorials

First Hibernate Application
First Hibernate Application In this tutorial you will learn about how to create an application of Hibernate 4. Here I am giving an example which will demonstrate you how can you make your application using Hibernate 4. To create 

Hibernate Tutorial Example

Hibernate 4
of deprecated code You can also migrate your Hibernate 3 code to Hibernate 4... examples on Hibernate 4. All the examples are supported with the source code...Hibernate 4 Hibernate 4 is the latest version of Hibernate which was released 

Hibernate Questions

Hibernate Question
Hibernate Question  Hi,i am doing hibernate mapping but i did not get the accurate concept of that so will you please send me a mapping between 2 table code. and at the time of mapping where we have to use the set<> method 

Hibernate Tutorial Example

Hibernate Tutorial: Learn Hibernate with examples
Hibernate Tutorial: Concise tutorial of Hibernate framework... of Hibernate Framework. Learn latest topics of Hibernate framework with the help of articles and example programs given here. Hibernate is popular open source ORM 

Hibernate Questions

Hibernate required jar files - Hibernate
Hibernate required jar files  Hi, What are the jar files are required for hibernate and Springs application. I want to run complete application springs and hibernate. Where it will be available? How can i use it i.e. 

Hibernate Questions

java - Hibernate
the code and run using Hibernate and annotation..plse help me...  Hi friend, Read for more information. http://www.roseindia.net/hibernate/hibernateannotations/hibernate-annotations-tutorial.shtml Thanks 

Hibernate Questions

JAVA - Hibernate
of by the developer manually with lines of code. Hibernate provides transparent persistence...JAVA  hello friends please answer me. 1. what is hibernate...? 2. why hibernate..? 3. Hibernate Vs JDBC...? plz plz plz answer me, i have 

Hibernate Questions

Hibernate log4j
Hibernate log4j  Hi, when i run the FirstExample.java given in the tutorial, i got the right output, what my doubt is from where i am getting the log4j messages, like log4j:WARN no appenders could be found for logger 

Development process Questions

spring hibernate
table through jsp using spring an hibernate....and the fields in the registration jsp are in different tables???can any one help or is there any sample code... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml 

Development process Questions

spring hibernate
table through jsp using spring an hibernate....and the fields in the registration jsp are in different tables???can any one help or is there any sample code... the following link: http://www.roseindia.net/hibernate/HibernateSpring.shtml 

Hibernate Questions

hibernate configuration with eclipse 3.1 - Hibernate
simple hibernate program code and with struts also. so please tell me the step by step process. i have that folder in d:/hibernate i thing...hibernate configuration with eclipse 3.1  Dear Sir, i got your mail 

Hibernate Questions

hi - Hibernate
hi  Hi , Thanks for response. Could anyone tel me what is findByExample method in Basic DAO class developed by hibernate reverse engintnering process. pls suggest me the apporopriate code using the above method . pls 

Struts Questions

struts and hibernate based health care project source code
struts and hibernate based health care project source code   Hi i need a struts and hibernate based online health care project source code with all the details. Please send as soon as possible. Thanks & Regards Prakash 

Struts Questions

struts and hibernate based health care project source code
struts and hibernate based health care project source code   Hi i need a struts and hibernate based online health care project source code with all the details. Please send as soon as possible. Thanks & Regards Prakash 

Spring Framework Questions

Spring and hibernate based Online Shopping project with source code
Spring and hibernate based Online Shopping project with source code  Hi all.. i need Spring and hibernate based Online Shopping project with source code. Please kindly send me all the project source code. Thanks & Regards 

Hibernate-Tutorials

Hibernate Native Entity Query
This section contains detail about Hibernate Native Entity Query with example code 

CVS Questions

GXT Grid moving right side after right alighnment
GXT Grid moving right side after right alighnment  I have created one gxt grid.there are 7 column and last column align as RIGHT .so grid width is moving right side 2px. so how can i fix 

Hibernate Questions

Persist a List Object in Hibernate - Hibernate
on hibernate. How to persist a List object in Hibernate ? Can you give me a working Code /Example for the same ? Help provided will be highly appreciated.... http://www.roseindia.net/hibernate/projections/hibernate-projections.shtml 

Hibernate Tutorial Example

Hibernate Mapping
Hibernate Mapping In this Hibernate Mapping tutorials series you will learn Hibernate in depth. We will show everything on Hibernate Mappings with running code example. We have used easy to learn examples that will help you understand 

Hibernate Questions

in connectivity - Hibernate
the hibernate and postgresql that progrram is running while showing no error... insertted  Hi friend, This is connectivity and hibernate configuration code com.mysql.jdbc.Driver jdbc:mysql://localhost 

Hibernate Questions

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 

Java-Tutorials

Hibernate Tutorial
Hibernate Tutorial This section contains the various aspects of Hibernate. Here we will read What is Hibernate, Features of Hibernate, Compatibility with the various databases, Hibernate dialect of various databases, Architecture 

Advertisements Advertisements
 

 

 

DMCA.com