Home Tutorialhelp Comment Please update the above code............

 
 

Comment

Sudeepta Majhee
Please update the above code............,
December 20, 2008 at 9:09 AM

Need to add Transaction statement and use createSQLQuery() instead of createQuery() method.
-----------------------------
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class DeleteHQLExample {

public static void main(String[] args) {
// TODO Auto-generated method stub
Session sess = null;
try{
SessionFactory fact = new Configuration().configure().buildSessionFactory();
sess = fact.openSession();
String hql = "DELETE FROM INSURANCE WHERE ID = 2";
Transaction tx = sess.beginTransaction();
Query query = sess.createSQLQuery(hql);
int row = query.executeUpdate();
tx.commit();
if(row == 0){
System.out.println(" Doesn't delete any row");
}else{
System.out.println(" Deleted row " + row);
}
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
sess.close();
}
}

}
View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
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) but keep receiving exceptions, not sure if I did some thing wrong, please help 

Hibernate Questions

delete query problem - Hibernate
delete query problem  SessionFactory fact = new Configuration... = sess. beginTransaction(); String hql = "delete from STUDENT where name = 'mitha...=query.executeUpdate(); tx.commit(); i coded the above query but the IDEA 6.0 

Hibernate Tutorial Example

Hibernate Update Query
Hibernate Update Query      ... is the code of our java file (UpdateExample.java), where we will update a field... a row of the insurance table. Here is the code of delete query 

Hibernate Questions

Hibernate - 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  Hai this is jagadhish while running a Hibernate 

Hibernate Questions

Hibernate delete example program
Hibernate delete example program  How to delete an object in Hibernate? In my program I have to write program to delete the data using Hibernate...() method of the Session object. Here is the sample code: //Delete the object 

Hibernate-Tutorials

Hibernate delete Query
Hibernate delete Query In this tutorial you will learn how to use HQL delete query in Hibernate. In this section we are discussing about the HQL delete query of Hibernate. Here we will give an example which will demonstrate you how 

Hibernate Questions

hibernate - Hibernate
hibernate  is there any tutorial using hibernate and netbeans to do a web application add,update,delete,select   Hi friend, For hibernate tutorial visit to : http://www.roseindia.net/hibernate/index.shtml 

Hibernate Questions

Blob update in hibernate
Blob update in hibernate  Hi , I wanted to upload a blob into mysql database using hibernate. Could you please help me . Thanks in advance, Satchidanand Mohanty 

Hibernate Questions

Dynamic-update not working in Hibernate.
Dynamic-update not working in Hibernate.  Why is dynamic update not working in hibernate?   Dynamic-update is not working. It means when you are running your update, new data is added in your table in place 

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

Delete HQL query - Hibernate
Delete HQL query  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query... could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please 

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 delete query :
hibernate delete query :   Hi, I m using Hibernate 3 + javadb my... NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table . My code is : try{ SessionFactory sessionFactory = new Configuration 

Hibernate Tutorial Example

Hibernate Delete Query
Hibernate Delete Query      ... database using the hibernate. Lets first write a java class to delete a row from...;2" Here is the code of delete query: DeleteHQLExample.java  

Hibernate Questions

delete row from a table using hibernate
delete row from a table using hibernate  //code in java file String hql="delete from CONTACT c where ID=6"; Query query=session.createQuery(hql); //error when executing above code CONTACT is not mapped 

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... problem please send me code. Visit for more information. http 

Blog

Hibernate tools update site
Hibernate tools update site Are you looking for hibernate tools update site... productivity. Hibernate tools update site is http://download.jboss.org/jbosstools/updates/stable From the above url you can download the latest version of Hibernate 

Hibernate Questions

Hibernate code - Hibernate
Hibernate code  firstExample code that you have given for hibernate... true org.hibernate.dialect.MySQLDialect update... inserted in the database from this file. http://www.roseindia.net/hibernate 

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 - Hibernate
Hibernate  what is difference between dynamic-update and dynamic... property and a tagged value to allow dynamic-insert and dynamic-update. ------------------------------------------- Please visit for more information 

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

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

SQL Question

DELETE
THE FOLLOWING ERROR Error Code : 1093 You can't specify target table 'EMP' for update in FROM clause ANY ONE PLEASE HELP ME. WITH REGARDS...DELETE   I AM DOING IT IN MYSQL. DELETE FROM EMP WHERE SAL> 

Java Technology Tutorials

CRUD application in hibernate annotation
:WARN Please initialize the log4j system properly. Hibernate..._ where student0_.id=? Hibernate: update student set scourse=?, sname... Hibernate: delete from student where id=?   

Hibernate Questions

Hibernate - Hibernate
Hibernate  when I run Hibernate Code Generation wizard in eclipse I'm... getting this error. please let me know, how to resolve...;Hi Friend, Please visit the following link: http://www.roseindia.net 

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 

Hibernate Questions

hibernate - Hibernate
-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter... Hibernate; import org.hibernate.Session; import org.hibernate.*; import...   Hi Radhika, i think, you hibernate configuration 

Hibernate Questions

Hibernate Association
Hibernate Association  1) <bag name="product" inverse="true" cascade="all,delete-orphan"> <key column="did"/> <... name="dealer" class=" net.roseindia.Dealer" column="did" insert="false" update 

Hibernate Tutorial Example

Hibernate 4
to persist, update, query and delete the persistence objects. Here are the major... 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 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=" 

Hibernate Questions

Hibernate required jar files - Hibernate
, Please visit the following link: http://www.roseindia.net/struts/hibernate-spring/index.shtml Download the full code from the above link and extract...Hibernate required jar files  Hi, What are the jar files 

Hibernate Questions

Hibernate
Hibernate  hibernate delete query execution 

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

Update not working in hibernate.
Update not working in hibernate.  Update not working in hibernate 

Hibernate-Tutorials

Hibernate update Method
an update method of Hibernate to update the record of table. Complete Code...Hibernate update Method In this tutorial you will learn about the update method in Hibernate Hibernate's update method saves the modified value 

Framework Questions

Hibernate - Framework
Hibernate  hi..... how i insert,update,delete data to Insurence table using nativesql query.i m not getting the code. thnx 

Hibernate-Tutorials

Hibernate update Query
Hibernate update Query In this tutorial you will learn about an update query in Hibernate This tutorial is based on how to write HQl update query in hibernate. In hibernate update query updates the data of the database table when 

Hibernate Questions

struts with hibernate - Hibernate
struts with hibernate  Can u send me Realtime example of struts with hibernate(Saving,Delete,update,select from muliple tables 

Hibernate Interview Questions

delete() method of hibernate
delete() method of hibernate  Define the use of delete() method of hibernate? Example 

Hibernate Questions

Hibernate criteria delete Example
Hibernate criteria delete Example  How to use the delete criteria in Hibernate? thanks 

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  Please tell me the difference between hibernate and jdbc 

Hibernate Questions

hibernate with srtuts
hibernate with srtuts  Can anybody Give me a example of delete records in hibernate with struts..   Please visit the following links: http://www.roseindia.net/struts/struts-hibernate/ http://www.roseindia.net 

Hibernate Tutorial Example

Hibernate beginner tutorial
to delete the entity using Hibernate. Above tutorials will help you...Hibernate the beginner tutorial - Essential Hibernate tutorials for beginner Hibernate: This beginning tutorial on Hibernate has been design to fulfill 

Hibernate Questions

Java - Hibernate
(); } } } --------------------------- Simple problem in your code. please change the setId..., this type of output. ---------------------------- Inserting Record Done Hibernate... not execute JDBC batch update 

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 Questions

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

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

HQL Update Statement to update database table
, SELECT, INNER JOIN, GROUP BY Statements except UPDATE, INSERT and DELETE... the example below... Example of UPDATE Clause in Hibernate: package..._ where insurance0_.ID=? Hibernate: update insurance set insurance_name 

Hibernate Questions

hi - Hibernate
; } } } pls let me know how to delete one particular record using this code...hi  hi all, I am new to hibernate. could anyone pls let me know... to delete a particular record using DAO. Here I provide MyEclipse automatiically 

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 

Hibernate Questions

hibernate firstExample not inserting data - Hibernate
.  Hi friend, Please send me code and explain in detail. Visit for more information. http://www.roseindia.net/hibernate/ Thanks. ...hibernate firstExample not inserting data  hello all , i followed 

Hibernate Questions

Hibernate
Hibernate  hi sir i need hibernate complete tutorial for download   Hi Friend, Please visit the following link: Hibernate Tutorials 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 

Hibernate Questions

Hibernate tutorial - Hibernate
. In our hibernate tutorial you will find many examples with running code. You can download the code from our website free of cost. Please visit http...Hibernate tutorial  can u provide me some material in hibernate.  

Hibernate Questions

How to update table in Hibernate
How to update table in Hibernate  Hi, I have a table in database that has two fields in it. Student Name and ID, can anyone explain me how to update these tables in Hibernate. Thanks.   Update table query in Hibernate 

Spring Framework Questions

spring with hibernate integration
spring with hibernate integration   i want code for update and find operation how can i update and search operations in one method by using multiaction controller?   Please visit the following link: http 

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

Hibernate Questions

Hibernate - Hibernate
Hibernate  how to update record by calling stored procedure from java prog using hibernate query   Hibernate update query http://www.roseindia.net/hibernate/hibernate-update.shtml This will show you how to update 

Hibernate Questions

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

Hibernate Questions

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

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

Use of delete() method in hibernate.
Use of delete() method in hibernate.  Define the use of delete() method of hibernate?   Hibernate provide the facility to delete one row... department0_ where department0_.id=? Hibernate: delete from department where id 

Hibernate Tutorial Example

Hibernate 4 create Session Factory: Example of creating Session Factory in Hibernate 4
the code for creating the SessionFactory instance in your application. Hibernate... to this version of Hibernate you will have to change the code. You should the latest...().buildSessionFactory(); If you use the above code to create SessionFactory 

Hibernate Questions

Please explain Hibernate Sessionfactory.
Please explain Hibernate Sessionfactory.  Hi there, Please explain Hibernate session factory in detail. I have just started learning hibernate so i... to Hibernate you can go through the following links which we have provided 

Hibernate Tutorial Example

Hibernate Architecture
of the hibernate is used to select, insert, update and delete the records form...: The above diagram shows that Hibernate is using the database... operations on the database like select, insert, update and delete the records 

Hibernate Questions

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

Hibernate Questions

hibernate
urgent please send me. thanks in advance thanks&regards teja   Hi Friend, Please visit the following link: http://www.roseindia.net/hibernate...hibernate  Hi Good Morning Will u please send me the some 

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 COMPOSITE ID - Hibernate
`) REFERENCES `employees` (`sno`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=latin1; Now i ahve to update the login time & logout time...HIBERNATE COMPOSITE ID  Hi, I have a database table structure 

Hibernate Questions

hibernate sql error - Hibernate
, Please visit the following links: http://www.roseindia.net/hibernate...hibernate sql error  Hibernate: insert into EMPLOYE1 (firstName..." org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update 

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... = session.createQuery("update LoginForm set logintime = '"+loginTime+"' where 

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

Complete Hibernate 4.0 Tutorial
Hibernate Update Query Hibernate Delete Query... Hibernate update Method Hibernate persist Method Hibernate... hibernate maven hibernate delete orphan hibernate hsql 

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
hibernate  1.difference between lazy=true and lazy=false? 2.difference between merge() and update()? 3.what is detached object 

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

Struts-Hibernate-Integration - Hibernate
Struts-Hibernate-Integration  Hi, I was executing struts hibernate intgeration code the following error has occured. Anyone can give me...) javax.servlet.http.HttpServlet.service(HttpServlet.java:802)   Hi Friend, Please visit 

Hibernate Tutorial Example

Hibernate Aggregate Functions(Associations and Joins)
and finally displays the requested data on the console. Here is the hibernate code...:WARN Please initialize the log4j system properly. Hibernate... Hibernate Aggregate Functions(Associations and Joins 

Hibernate-Tutorials

Hibernate Tutorials
Understanding Hibernate O/R Mapping Hibernate Update Query Hibernate Delete Query...Hibernate Tutorials Hibernate is popular open source object relational mapping... to providing mapping of Java classes to database tables, Hibernate also 

Blog

Sitemap Hibernate Tutorial
Update Query | Hibernate Delete Query | Introduction to Hibernate Query...; Tutorial Section Introduction to Hibernate 3.0 | Hibernate Architecture | First Hibernate Application | Running the Example in Eclipse | Understanding 

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

Intro please - Hibernate
Intro please  Hi, Anyone please tell me why we go for hibernate? is there any advanced feature? Thanks, Prabhakaran.  Hi friend, Here is the detail information about hibernate. Read for more 

Hibernate Questions

hibernate...............
hibernate...............  goodevining. I am using hibernate on eclipse, while connection to database Orcale10g geting error .........driver ARNING...) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423) ... 7 more please suggest me 

Hibernate Questions

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

Hibernate Tutorial Example

Hibernate Architecture
: Create mapping meta-data Step 4: Write code to perform create, read, update and delete operations. Hibernate uses the Java classes which represents... to perform operations like select, insert, update and delete the records in the table 

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

delete row from a table in hibernate
delete row from a table in hibernate  is there method to delete row in a table using hibernate like save(-) to insert row 

Hibernate Questions

Problem in running first hibernate program.... - Hibernate
/hibernate/hibernatetools/hibernate-tools-update-site.shtml Again I downloaded...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 4 Simple Example
as salary0_0_ from Worker worker0_ where worker0_.id=? Hibernate: update Worker set...=? Hibernate: delete from Worker where id=? Hibernate: select worker0_.id as id0_, worker0...Hibernate 4 Simple Example This section contains a simple Hibernate 4 example 

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 

Development process Questions

Delete database Table through hibernate and Spring
Delete database Table through hibernate and Spring  Hi, I am using Spring,Hibernate and Tapestry to save and also fetch data simultaneously from... is UserManagerImpl code: package tuto.webssh.service.impl; import java.util.List; import 

Eclipse Plugins

Hibernate Synchronizer
Hibernate Synchronizer is a free Eclipse plugin code... will automatically generate java code when your hibernate mapping files are modified... your Hibernate mapping files are changed, the plugin will re-write the code 

Hibernate Tutorial Example

Learn Hibernate programming with Examples
with code examples: Hibernate 4 Features - Learn the new features... in Hibernate Hibernate save or update method example - In this example you...() Example - Learn how to delete the entity using Hibernate. Learn more 

Hibernate Interview Questions

hibernate
hibernate  please let know the most likely asked questions in the interview assoonaspossible. my interview is tomarrow please send me as soon as possible.Hibernate questions Regards, Shweta 

Servlet Interview Questions

servlet code to update password?
users.then Store it into a table. please tell me the code for the above question...servlet code to update password?  Create a servlet page which helps the user to update his password. The user should give the username,old password 

Advertisements Advertisements
 

 

 

DMCA.com