Home Tutorialhelp Allcomments Hibernate Runninge Xample

 
 

Comments

 
User Comments for the tutorial:

Running First Hibernate 3.0 Example



Advertisement
Comments

This is great!
I am new to this hibernate/eclipse thing, but my goodness! this is so wonderful. Good work guys. 

Hibernate 3 - run sample error
I followed the tutorial but can not run the example. I got the following exception when running the sample code: Exception in thread "main" java.lang.NullPointerException at roseindia.tutor.hibernate.FirstExample.main(FirstExample.java:39) I tr 

i got an error
I got this when i tried to run it...... log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record Done Exception in thread "main" org.hibernate.exc 

I am getting following error
Exception in thread "main" java.lang.ExceptionInInitializerError at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:16) Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationEx 

Can not insert data
I ran the application and got output as shown in tutorial. but it did not insert any record in database. I am using oracle 10g and my setting is <property name="dialect">org.hibernate.dialect.OracleDialect</property> is it wrong ? 

java
how to create web page using Hibernate  

re: row not inserted
hi, if row in not inserted try following: Transaction tx = session.beginTransaction(); .... . ... tx.commit(); 

error in first hibernate program
while implementing first hibernate code i am getting NullPointerException in main. 

wonderful site
its really working ... good job..guys.. 

Its a 'commit' issue
Its a 'commit' issue .Add the below line to hibernate.cfg.xml. <property name="hibernate.connection.autocommit">true</property>"  

Successfuly Worked
Thanks to Rose India, and thanks to Deepak, for implementing Hibernate, in such a simple fashion. This program has really worked for me. And helped me to enhance it, for complex application. Thanks again. If any of you, get problem in inserting da 

Fix for Null Pointer exceptions
Hi Carl, You get the following exceptions when you do not have the mysql-connector-java-3.0.16-ga-bin.jar and mysql-connector-java-3.1.6-bin.jar in the Java build path ------------------ Exception in thread "main" java.lang.NullPointerException  

The same problem
I bumped into the same problem as you did. 

SOLUTIONS FOR THE PROBLEMS WITH THIS TUTORIAL
hi At first you will have to change your hibernate.cfg.xml to indicate which username and password and port will be used to establish the connection. Then you can create a database named hibernatetutorial (the hibernate won´t do it for you in t 

SOLUTIONS FOR THE PROBLEMS WITH THIS TUTORIAL
hi At first you will have to change your hibernate.cfg.xml to indicate which username and password and port will be used to establish the connection. Then you can create a database named hibernatetutorial (the hibernate won´t do it for you in t 

data not inserting into database
data not inserting into database but progrm is executed successfully 

data not inserting into table
hi , data not inserting into table created the table as : CREATE TABLE `contact` (  

data not inserting after ececution of program
data not inserting after ececution of program i get Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?) message but no data found in contact table please help 

Problem
I found this error when i try to run the sample application org.hibernate.HibernateException: /hibernate.cfg.xml not found 

Possible solution for row not getting inserted
Hi, For those who are not able to insert the row in the database, just try the follwing code and check.. Transaction tc = session.beginTransaction(); session.save(contact); tc.commit(); In other words, just commit the transaction.. Saw t 

Solution to insertion problem in firstexample.java
After sessionfactory.opensession() method, add below line: Transaction trx = session.beginTransaction(); and After session.save(contact) method, add below line: trx.commit();  

Hibernate Example
I am getting the following error when I try to run the FirstExample.java in eclipse. Exception in thread "main" java.lang.NullPointerException at roseindia.tutorial.hibernate.FirstExample.main(FirstExample.java:36) Does anyone has a fix for t 

didn't insert data
For some reason, my application didn't insert any data into the table. What's wrong? 

Reply to the questions asked in the forum
Reply to the questions asked in the forum(after the question).Make the tutorial as small as possible. I downloaded the tutorial and I am able to see many unwanted things which are not required to run a simple program(it may confuse). I too had the sa 

Solution for getting nullpointer
If you are getting nullpointer then there is problem like include all the jar files which are need for hibernate then it will work fine required jar files for hibernate are: hibernate3.jar dom4j.jar commons-logging.jar commons-collections.jar 

If you're getting the null error
You have to create the table for contact for this to work CREATE TABLE `Contact` ( `id` int(11) NOT NULL default '0', `firstname` varchar(20) NOT NULL default '', `lastname` varchar(20) NOT NULL default '', `email` varchar(30) default NULL, P 

Problem Running FirstExample
Hello everyone, I am new to Hibernate and trying to execute the FirstExample in this tutorial. I am getting the following message. Not clear on what I missed. I have added all the below said jars in the classpath of my eclipse project. and also 

client code not correct
hi client code(main is not correct) bcz you are not begin Transaction and close the Transaction . here find the correct code package roseindia.tutorial.hibernate; import org.hibernate.HibernateException; import org.hibernate.Session;  

Error give When Run Project
[I'm chanaka When I Run the sample project it gives following error........] run-single: Nov 20, 2008 3:44:29 PM org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.0rc1 Nov 20, 2008 3:44:29 PM org.hibernate.cfg.Environment <clinit>  

You missed at least 2 jars
@preeti Thanks for that list... However, in order to get this to work, I also needed to add: slf4j-1.5.6 javassist.jar  

need Transaction to insert the data into DB
When the application and got output as shown in tutorial. but it did not insert any record in the database. The reason is because the database operation need to be enclosed in a transaction and the it should be commited. Here is the sample code: 

LoggerError
When i was runnig the firstExample i hava a problem in NoClassDefFoundError 

Thanks a lot!
Perfect tutorial.. 

Bug in FirstExample.java
Hi (whoever wrote this example), The code in FirstExample.java is incomplete. It will compile and execute fine but will now insert any records in the DB. Change it as below: Transaction tx = session.beginTransaction(); Contact contact = new C 

apllication not running
while running this apllication i m getting like editor does't have main type. 

i m getting error while running this application
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connec 

Hibernate source code.
Hibernate source code is very nice. 

NoClassDefFoundError
When i was runnig the firstExample i hava a problem in NoClassDefFoundError java.lang.NoClassDefFoundError: roseindia/tutorial/hibernate/FirstExample Exception in thread "main" I am add the all jar files SessionFactory sessionFactory = new C 

perfect tutorial
This is a perfect tutorial. but as mentioned in the comments add the transaction statement to complete the inserting. 

Cannot run FirstExample: UnsupportedClassVersionEr
Hallo, I followed the tutorial, created the sample project in myEclipse, but cannot run FirstExample. It gets an UnsupportedClassVersionError. Please, advice if possible. Stacktrace: ava.lang.UnsupportedClassVersionError: Bad version number 

No getting the output at 2nd stage
Caused by: java.sql.SQLException: Invalid authorization specification message from server: "Access denied for user 'root'@'localhost' (using password: NO)" is what am getting.when my username and password are "root"  

the data base
what about the data base in this exemple?  

an error in first exam.
-- Copy contact.hbm.xml, and hibernate.cfg.xml in the bin directory of the project using windows explorer. What is target forder? -- I download the example and try to run but failed to appear exception following Exception in thread "main" jav 

Unresolved compilation problems:
which file i need to run as java application? if i select the project, then i am facing the below issue: Exception in thread "main" java.lang.Error: Unresolved compilation problems: Session cannot be resolved to a type SessionFactory cannot 

application run but not insert any value in DB
i follow all above steps, now i m trying to run the application. On console screen it show above output message, but it can't insert any value on my DB tables??? can you please explain why not it insert any value in DB tables ??? 

Error in the code
Exception in thread "main" java.lang.NullPointerException at FirstExample.main(FirstExample.java:34)  

Running Hibernate Program
If Data is not Saved in table . then you must add the Tranction object Transaction tx = session.beginTransaction(); 

I have no rows in the contact table!
Hello, I ran the example using MYSQL 5.1 and Intellij 7.5. After FirstExample.java runs I get the message "Inserting Record Done Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)". There are no errors. Whe 

Solved insertion problem.
I finaly got the row permanently inserted into the database. I changed my FirstExample.java code to the following. public class FirstExample { public static void main(String[] args) { Session session = null; try{ // This s 

Transaction being & commit
Thank you very much arun..... I got my code worked successfully after adding the transaction begin and transaction commit lines. Thanks. 

Output is not coming throwing exception
What you have said I follow all the steps but I am not able to get the output. Exception is: Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handled 

Can I do multiple inserts within same session / tr
Can I do multiple inserts within same session / transaction? But it was failed for me. See the example below : SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session = sessionFactory.openSession(); org.h 

Plz change the code
As when we will run this code it will generates errors . As the session was not started in a transaction, plz made correction to this. 

Thanks RoseIndia
Hi I get this error when i run this program log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record Done Exception in thread "main" org.hi 

Problem running FirstExample
Nice tutorial sir. But it seems that I can't run the FirstExample properly Exception in thread "main" org.hibernate.exception.GenericJDBCException:Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(Err 

hibernate example
thanks roseindia this code is workin perfectly.Guys just add Transaction tx = session.beginTransaction(); and tx.commit(); after session.save(), values will be inserted. good luck 

JSBCTrancation
Hi, I have used JDBCTrancration class insted of Transaction Interface, that worked fine.as JDBCTranction uses Transaction,but when I use Transacton interface it is showing exception. 

NullPointerException when creating SessionFactory
Hi, For those of u who r getting NullPointerException while creating sessionfactory (SessionFactory sf = new Configuration().configure().buildSessionFactory();) import all required jar files.. View the readme file in lib directory to get the list 

hi when i run the above example iam getting errors
can some one help me to solve this log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Inserting Record Done Exception in thread "main" org.hibernate.exceptio 

Program execution successful , but no data in tabl
Hi, I am using the Oracle DB. I am able to execute the program with out any errors. It is also showing the Insert Command as it is shown in the output here. But when i check the CONTACT table in the schema there is no record. Could you please hel 

I'solved the same bug.
Hy Roland, try to change the Contact table engine to MyISAM using a MySql tool like MySqlBrowser with this command : ALTER TABLE `hibernatetutorial`.`contact` ENGINE = MyISAM ROW_FORMAT = DYNAMIC;  

rows
Hi Roland, same problem here with no errors and no rows. After I used transactions, i got rows in my db :) Try this: ... session =sessionFactory.openSession(); Transaction tr = session.beginTransaction(); Contact contact = new Co 

Exception in thread "main" org.hibernate.exception
Use latest jar: cglib-nodep-2[1].1_3.jar 

Insert problem
Hello, I am running this example (exactly as is) and the new row is not populated in DB. I am running the query select(*) from contact and get 0 rows as result. My console shows the exactly same as yours in runtime. Please advice. Many thanks in 

Good Job
Thanks for keeping up with the simplicity on ORM and Hibernate concepts. I was able to understand this concept with in few mins. Good job guys ! 

Worked Perfectly
@Deepak and Arun(Your snipplet for transcation management completed this tutorial) Nice tutorial! worked perfectly! 

appreciation
excellent website for learning 

complete code
the solution given by sudhir and others make above example working and complete,,thanks. Change it as below: Transaction tx = session.beginTransaction(); Contact contact = new Contact(); contact.setFirstName("Arun"); contact.setLastName("Jain" 

Solution is here..complete code of FirstExample
package roseindia.tutorial.hibernate; import java.util.List; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; /**  

The above code should have transaction as well
The above code failed to insert the date into the table cause: Client application code does not have begin transaction and the assigment to the transaction interface. 

What about in NetBeans?
Will it work in Netbeans? 

Use Autocommit if not using transaction
In Above example..Always use <property name="connection.autocommit">true</property> in your xml configuration file if you are not using transaction otherwise you will not able to see the record in Database.  

Use Autocommit if not using transaction
In Above example..Always use <property name="connection.autocommit">true</property> in your xml configuration file if you are not using transaction otherwise you will not able to see the record in Database.  

getting error while running the firstexample
getting error while running the firstexample in eclipse. These lines can not be resolved:...... import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration;  

who wil create table in DB???
learners may also mistake that it is hibernate which wil create the tabe on its own in the DB... so please include the table creation process 

problem running firstexample.java
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCodeConverter.java:92) at org.hibernate.exception.ErrorCodeConverter.co 

First Hibernate 3.0 Example
I have followed your instructions but am not able to run the application. Is there something special has to be set up in Eclipse? 

for inserting data in database correctly
org.hibernate.Transaction tx = session.beginTransaction(); //Create new instance of Contact and set values in it by reading them from form object System.out.println(" Inserting Book object into database.."); Bo 

run successfully but ...
run successfully but no record insert anybody know please help me about it  

after modifying works fine,change FirstExample
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; pub 

comment
very good program. i am trying to oracle connection. same output generated. how to implement dynamically.... crate ,insert and deleted 

No records inserted
Thanks Arun! 

Why we need a transaction to store the record. ?
The code failed as the transction was not created. Since session.flush() sends the query to database and runs the query. still the code was not working. Please can you help me understanding the code 

Hi
we may reqiured to update hibernate.cfg.xml file <property name="hibernate.connection.url">jdbc:mysql://localhost:3307/hibernatetutorial</property> and also u may reqiured to edit password in this file.  

Java
Your site is Really Super hints and guide for developers... 

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

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 

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 

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.   

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 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 

Programming Tutorials

Writing Great Articles is Difficult
Writing Great Articles is Difficult       Articles are a means of marketing your blogs and websites to readers as well as search engines, totally free of cost. Articles form one 

Hibernate Questions

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 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-Tutorials

Hibernate Video Tutorial
with great examples as our hibernate video tutorials are made by group of expert...Roseindia.net provides you the best Hibernate video tutorials embedded... the basics of hibernate as well as advance hibernate. Hibernate, which 

Advertisements Advertisements
 

 

 

DMCA.com