Home Tutorialhelp Comment Problem in this "FirstExample" class

 
 

Comment

K.Senthuran
Problem in this "FirstExample" class,
December 18, 2008 at 6:40 AM

There is a problem. In this "FirstExample" class
session =sessionFactory.openSession();
//Create new instance of Contact and set

//Here transaction should begin.

Transaction trx = session.beginTransaction();


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

// Transaction should be commited here

trx.commit();

System.out.println("Done");



If we dont mention the transaction the database will not update.

In this "FirstExample" class Transaction commit is missing.
Please update the class. It is very helpful for the beginners.
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
Hibernate Questions

hibernate firstExample not inserting data - Hibernate
hibernate firstExample not inserting data  hello all , i followed... * */ public class FirstExample { public static void main(String... class FirstExample { public static void main(String[] args) { Session 

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

Problem in running first hibernate program.... - Hibernate
Problem in running first hibernate program....  Hi...I am using.../FirstExample Exception in thread "main" " http://www.roseindia.net/hibernate/runninge..., It seems that your class has not been found.There may be problem in your 

Hibernate Questions

Java - Hibernate
, this type of output. ---------------------------- Inserting Record Done Hibernate... org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class FirstExample { public static void main(String[] args) { Session session = null 

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...------------------------ public class DemoController extends AbstractController 

Hibernate Questions

Problem with Hibernate or 11g
Problem with Hibernate or 11g  Hi I am using Hibernate and 11g in my project. The problem I am facing is I am executing a query from java class... on Created date column by using hibernate query language. The Problem is every 

Hibernate Questions

Problem in updating query in Hibernate - Hibernate
Problem in updating query in Hibernate  Hi, I have used a query.... Bean class is created for this set collection as well but still the values..., Please visit the following link: http://www.roseindia.net/hibernate 

Hibernate Questions

Eclipse hibernate problem
Eclipse hibernate problem  hie..i've just started a basic hibernate... and created a pojo class. I have created HibernateUtil class but I'm getting...;Hibernate Eclipse Integration Hibernate Tutorials 

Hibernate Questions

Hibernate @ManyToOne persisting problem - Hibernate
Hibernate @ManyToOne persisting problem  hello, In my apllication... wrote the code (summary) below.. class Class: @Id @GeneratedValue @Column(name="CLASS_ID") private Integer id; private String name; @ManyToOne 

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 Questions

hibernate pojo setter method problem
hibernate pojo setter method problem  how to pass a date type variable to a setter method in hibernate pojo class? //this is my pojo class import java.util.*; public class Employee { private String empname; private int 

Hibernate Questions

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

Hibernate Questions

hibernate problem
hibernate problem  please help me.... log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please...:12) i am getting this prob while running my hibernate program in Eclips please 

Hibernate Questions

Hibernate code problem - Hibernate
Hibernate code problem  Hi, This is Birendra Pradhan.I want... & Regards Birendra  Hi friend, For solving the problem visit to : http://www.roseindia.net/hibernate/index.shtml Thanks 

Hibernate Questions

Webservices(Axis2 + tomcat ) Consuming Hibernate Giving Problem - Hibernate
Webservices(Axis2 + tomcat ) Consuming Hibernate Giving Problem  Hi Please tell me how can i integrate hibernate in axis2 for my webservice?? I tried in some ways..but its not working..Main problem is hibernate session 

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

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 

Hibernate Questions

hibernate insertion problem - Hibernate
hibernate insertion problem  Hi , Thanks for the material .Its very gud . when i run FirstExample.java i get the message insertion has been done int the table contact . but whne i look into database data is not inserted 

Hibernate Questions

hibernate code problem - Hibernate
hibernate code problem  String SQL_QUERY =" from Insurance...: " + insurance. getInsuranceName()); } in the above code,the hibernate...= request.getParameter("name"); For more information on hibernate visit to : http 

Java Beginners

Problem
Problem  import java.io.*; import java.net.*; public class EchoClient { public static void main(String[] args) throws IOException { Socket echoSocket = null; PrintWriter out = null; BufferedReader 

Java Beginners

problem
problem  import java.io.*; class ranveer { public static void main(String args[])throws IOException { BufferedReader in =new BufferedReader(new InputStreamReader(System.in)); int m=Integer.parseInt(in.readLine()); int n 

Java Beginners

Problem
Problem  import java.io.*; import java.net.*; public class EchoClient { public static void main(String[] args) throws IOException { Socket echoSocket = null; PrintWriter out = null; BufferedReader 

Struts Questions

Struts-problem With DispatchAction Class
Struts-problem With DispatchAction Class  hi this is Mahesh...i'm working with struts 1.3.10....I have created an application which uses...: org/apache/struts/actions/DispatchAction Can any one help me with this problem 

Hibernate Questions

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

Hibernate Questions

server problem - Hibernate
server problem  dear sir please give me best soloution how run hibernate and spring application on jboss and weblogic10.1.0 sever and compile thanks 

Java Beginners

pojo class having problem
pojo class having problem  Cannot find any information on property 'Username' in a bean of type 'LoginBean.LoginBeanClass' org.apache.jasper.runtime.JspRuntimeLibrary.handleSetProperty(JspRuntimeLibrary.java:664 

Hibernate Questions

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 Questions

delete query problem - Hibernate
correctly , the problem is only delete query. 2) query.executeUpate(); ->...(); Read for more information. http://www.roseindia.net/hibernate Thanks 

Hibernate Questions

Problem with open connection - Hibernate
Problem with open connection  Hi Team, I am running one hibernate application and the database is ORACLE 10g.I am getting the below error.I connected to the database by using JDBC(with same driver and url).Please tell me 

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... version " please give me the suggestion to sort out the problem 

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 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... class are defined persistence. Example: package net.roseindia.table; import 

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

hibernate
hibernate  what is problem of tree loading 

Hibernate Questions

hibernate annotations
hibernate annotations  I am facing following problem, I have created... hibernate annotations to insert records into these tables. But it is trying... javax.persistence.Table; @Entity @Table(name="student_tbl") public class Student 

JSP Interview Questions

Oracle Database connectivity probem
firstexample; import java.sql.*; public class FirstExample { public static void... am trying to solve the problem from last three to four week but still not success 

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

Hibernate
Hibernate  what is the purpose of generator class in hbm file 

Hibernate Questions

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... org.hibernate.cfg.Configuration; public class DeleteHQLExample { public 

Hibernate Questions

Hibernate - Hibernate
one example   Hi mamatha, Hibernate 3.0, the latest Open Source... not understandable for anybody learning Hibernate. Hibernate provides a solution to map database tables to a class. It copies the database data to a class. In the other 

Hibernate Questions

hibernate - Hibernate
hibernate  Hai,This is jagadhish I have a problem while developing..., As per your problem exception is related to ant.Plz check the lib for Ant. For read more information: http://www.roseindia.net/hibernate/index.shtml 

Hibernate-Tutorials

Hibernate create POJO classes
Hibernate create POJO classes In this tutorial you will learn how to create a POJO class in Hibernate. POJO (Plain Old Java Object) is a programming model...) to create a classes that implements the entities of the business problem. These can 

Hibernate Questions

Hibernate - Hibernate
-mapping-3.0.dtd"><hibernate-mapping><class name="...Hibernate SessionFactory  Can anyone please give me an example of Hibernate SessionFactory?  Hi friend,package roseindia;import 

Hibernate Questions

Hibernate - Hibernate
Hibernate  when I run Hibernate Code Generation wizard in eclipse I'm... it. org.hibernate.console.HibernateConsoleRuntimeException: Problems while loading database driver class.../hibernate/index.shtml Hope that it will be helpful for you. Thanks 

Hibernate Questions

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 

Hibernate Questions

Hibernate - Hibernate
Hibernate  I am trying to connect hibernate with ejb2.0 stateless session bean, my application sucessfully deploy in weblogic server but when i execute the client application i got an error message that class not found exception 

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

Hibernate - Hibernate
){ System.out.println(e.getMessage()); } finally{ } }}hibernate mapping <class name...Hibernate pojo example  I need a simple Hibernate Pojo example ... java.util.*;public class pojoexample { public static void main(String arg 

Hibernate Questions

hibernate - Hibernate
Hibernate; import org.hibernate.Session; import org.hibernate.*; import org.hibernate.cfg.*; import java.util.*; public class NewHibernateSample { public...) The content of element type "class" must match "(meta*,subselect?,cache?,synchronize 

Hibernate Questions

Hibernate - Hibernate
Hibernate  Hai this is jagadhish, while executing a program in Hibernate in Tomcat i got an error like this HTTP Status 500.... Hopefully this will solve your problem. Regards Deepak Kumar 

Hibernate Questions

hibernate - Hibernate
hibernate  I have written the following program package Hibernate; import org.hibernate.Session; import org.hibernate.*; import org.hibernate.cfg.*; import java.util.*; public class NewHibernateSample { public 

Hibernate Questions

hibernate - Hibernate
hibernate  hi i am new to hibernate. i wan to run a select query... class SelectHQLExample { public static void main(String[] args) { Session... hibernate for use SessionFactory sessionFactory = new Configuration 

Hibernate Interview Questions

Tomcat installation problem - Hibernate Interview Questions
Tomcat installation problem   Hello 

Hibernate Questions

Hibernate generation Id to postgreSQL
Hibernate generation Id to postgreSQL  Hi, I'm trying to implement a id generator in Hibernate, but I'm having a problem. Hibernate doesn't seems... have a table (that entries were done with Hibernate script): carId|car 

JSP Servlet Questions

Problem to get connection from DAO class to JDBC
Problem to get connection from DAO class to JDBC  package controller; import java.sql.Connection; import java.sql.DriverManager; public class ConnectionProvider { private static Connection con=null; //static Connection 

Hibernate Questions

composinte primary key in hibernate
of getting pojo class object. Please help me in resolving this problem. I...composinte primary key in hibernate  I am facing following problem.... After doing hibernate reverse engineering, by default it has taken composite 

Hibernate Questions

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

Hibernate Questions

spring hibernate - Hibernate
with hibernate?  Hi friend, For solving the problem Spring with Hibernate visit to : http://www.roseindia.net/spring/index.shtml http://www.roseindia.net/struts/hibernate-spring/index.shtml Thanks 

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

Hibernate:What is hibernate?
| Database Server Hibernate provide a way of mapping of applications class...Hibernate:What is hibernate?  What is hibernate?   Hibernate: -Hibernate is an Open Source persistence technology. It provides Object 

Hibernate Questions

creating table in hibernate
of hibernate   There are 2 alternatives to create table in hibernate: 1... ========================================== /* Class Course */ package com.mypkg.course; import java.io.Serializable; public class Course implements Serializable { /** * */ private 

Hibernate Questions

Hibernate error - Hibernate
Hibernate error  I had run hibernate first example but it an error..., Please explain in detail your problem so that we can discuss and solve it. If you want more examples of Hibernate please visit the following link. http 

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... initialisation of persistent instances of the class. Initially hibernate...Hibernate:What is Hibernate proxy?  What is Hibernate proxy?   

Hibernate Questions

Hibernate delete HQL - Hibernate
Hibernate delete HQL  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate 

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

Hibernate error - Hibernate
Hibernate error  I hava following error while running hibernate.../tutorial/hibernate. But I have following error. log4j:WARN No appenders...(FirstExample.java:35) /hibernate.cfg.xml not found Please solve this problem 

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...; Hi friend, Annotation is the java class which is read through reflection 

Java Interview Questions

problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other 

Hibernate Questions

jsp-Hibernate Error - Hibernate
jsp-Hibernate Error  hi, my problem is, I designed an Interface where i am tring to listing the all rows of a table using Iterator and putted a link for deleting each row. I am deleteing row using row id of that record.it delete 

Hibernate Questions

Hibernate+JSF+Spring - Hibernate
Hibernate+JSF+Spring  i am facing the same problem. i have invited in Gtalk for chating. u can suggest ur convenience time to chat, so that i can ask my queries directly. i will be highly obliged 

Hibernate Questions

JSP with hibernate
JSP with hibernate  Hai Friend, As I new To hibernate, I'm facing problem in My project(JSP with hibernate) I need a tutorial who to devllope application with hibernate and jsp ana library jstl only plz can any one help for my 

Applet Questions

PROBLEM IDENTIFICATION
PROBLEM IDENTIFICATION  class MOrders { int nooforders; // Data members of the class public int getorder() { nooforders = 500; } public void displayorders() { System.out.println("The number of orders to be delivered 

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 not able to get. the hbm file is: IB_PAYMENT_SEQ 

Hibernate-Tutorials

Hibernate saveOrUpdate Method
Hibernate saveOrUpdate Method In this tutorial you will learn about the saveOrUpdate method in Hibernate. Hibernate's saveOrUpdate method inserts the new...() method can be used in Hibernate. For this I am giving a complete source code 

Hibernate Questions

Hibernate Isolation Query. - Hibernate
Hibernate Isolation Query.  Hi, Am Using HibernateORM with JBOSS server and SQLSERVER.I have a transaction of 20 MB, when it is getting processed... for the problem 

Hibernate Questions

Reagrsding Hibernate joins - Hibernate
-mapping-3.0.dtd"><hibernate-mapping> <class name="...Reagrsding Hibernate joins  Hi, I am trying to make join in Hibernate... org.hibernate.SessionFactory;import org.hibernate.cfg.Configuration;public class 

Java Beginners

Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping... if the input string contains equal number of A's and B's. class StringEx { public 

Hibernate-Tutorials

Hibernate update Method
Hibernate update Method In this tutorial you will learn about the update method in Hibernate Hibernate's update method saves the modified value... in Hibernate. For this I am giving a complete source code which can be downloaded 

Java Beginners

PROBLEM IN EXECUTION
PROBLEM IN EXECUTION  class R { private int x; private int y...); } } class J { public static void main(String args[]) { R c1,c2; c1... to access the private variable, method of another class. class R { int x 

Hibernate Questions

Hibernate Criteria Queries - Hibernate
Hibernate Criteria Queries  Can I use the Hibernate Criteria Query... org.hibernate.cfg.Configuration; public class HibernateExample { public... Configuration(); // configuring hibernate SessionFactory 

Hibernate Questions

hibernate Excetion - Hibernate
hibernate Excetion  The database returned no natively generated identity value Even i mentioned in generator class as native still am getting the same error that Hibernate: insert into login (uname, password) values 

Spring Framework Questions

Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes
Problem in Spring 3 MVC and Hibernate 3 Example tutorial source codes  I referred your tutorial "Spring 3 MVC and Hibernate 3 Example" and downloaded...) ..... So please help me to solve this problem. I want to know is something 

Struts Questions

struts url problem in Switching module using SwitchAction class - Struts
struts url problem in Switching module using SwitchAction class  when i use SwitchAction class,it creates a problem take a examle when i go... that creates a problem in the link of that jsp page ,after clicking that links , i got 

Hibernate Questions

What is hibernate ?
Hibernate provide a way of mapping of applications class to the database table...What is hibernate ?   What is hibernate ? explain with simple example.   Hibernate is an Open Source persistence technology. It provides 

Java Beginners

Servlet problem
problem from last three month and now i hope rose india developers... connectivity code it works but problem is with servlet page. My servlet code...; public class MyServlet extends HttpServlet { public MyServlet 

Java Beginners

Problem in setting IP address for a JFrame Class Desktop Application
Problem in setting IP address for a JFrame Class Desktop Application  I have designed a browser for our final year project, it is working well. But when we put it in a system which has a proxy setting for internet connection 

JDBC Questions

jdbc problem
jdbc problem   hi my name is mohit...i am making a project in java... a lot... 1)login page(this is made in swings) public class loginpage extends...(this is made in java class) public class loginconnection { public static void 

JSP Servlet Questions

solve this problem
in table please tell me the solution for thid problem import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class... javax.servlet.*; import javax.servlet.http.*; public class DataInsertion 

JSP Servlet Questions

problem in database
problem in database   thanks for web site. I want change this code to insert data into PostgreSql database using jsp,servlets. but i getting... class ServletUser extends HttpServlet { try { Class.forName 

Hibernate Questions

hi i m new to hibernate..plzzzzzzzzzzzzzz help me.... - Hibernate
hi i m new to hibernate..plzzzzzzzzzzzzzz help me....  hi friends i m new to hibernate..& i m stuck in one positon in my pgm.. its a simple select... indiabulls.test; public class Contact { private String firstName; private String 

Java Beginners

GUI problem
GUI problem  Create a class called CDProgram and write a GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows: Amount deposited: 80000.00 Years: 15 Interest Rate: 7.75 Hint 

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 

Java Beginners

jcuda problem
to use them cause there were no make file or installation script i tried class-path option set the class path many time with many option but nothing 

Swing AWT

StringToenizer Problem
java.util.*; class ConvertStringTokenizerToString { public static void main(String 

Hibernate Tutorial Example

Hibernate 3.1.3 Released
Hibernate 3.1.3 Released Back to Hibernate Tutorials Page Hibernate... service. Hibernate lets you develop persistent classes following object-oriented..., and collections. Hibernate allows you to express queries in its own portable SQL extension 

Hibernate Questions

HIBERNATE COMPOSITE ID - Hibernate
HIBERNATE COMPOSITE ID  Hi, I have a database table structure as CREATE TABLE `attendance` ( `sno` int(11) NOT NULL auto_increment... to help in mapping file and pojo class. Thanks in advance 

Java Beginners

connectivity problem
java.util.*; class Test { static { try{ Class.forName 

Hibernate Questions

hibernate annotations with composite primary key
hibernate annotations with composite primary key  I want to know how to use hibernate annotations in case of composite primary key in one table. I...="student_tbl") @IdClass(StudentID.class) public class Student implements 

JDBC Questions

result problem
javax.servlet.*; import javax.servlet.http.*; import java.sql.*; class filedata extends...*; public class Data extends HttpServlet { public void doPost(HttpServletRequest 

Advertisements Advertisements
 

 

 

DMCA.com