| Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Spring Framework | Web Services | BioInformatics | Java Server Faces | Jboss 3.0 tutorial | Hibernate 3.0 | XML | ||||
|
||||
|
|
||||
| Tutorial Categories: Ajax
| Articles
| JSP
| Bioinformatics
| Database
| Free
Books |
Hibernate
| J2EE
| J2ME
| Java
| JavaScript
| JDBC
| JMS
| Linux
| MS
Technology |
PHP
| RMI
| Web-Services
| Servlets
| Struts
| UML
|
|
||||||||||||||||||||||||||||||
|
Home | JSP | EJB | JDBC | Java Servlets | WAP | Free JSP Hosting | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs |
||||||||||||||||||||||||||||||
Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.
Copyright © 2007. All rights reserved.
Current Comments
18 comments so far (post your own) View All Comments Latest 10 Comments:the example does not work. the following exception is thrown:
java.lang.NullPointerException
at org.hibernate.hql.antlr.HqlSqlBaseWalker.path(HqlSqlBaseWalker.java:2193)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2232)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:498)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.deleteStatement(HqlSqlBaseWalker.java:276)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:801)
at org.hibernate.impl.QueryImpl.executeUpate(QueryImpl.java:89)
at roseindia.tutorial.hibernate.DeleteHQLExample.main(DeleteHQLExample.java:27)
Posted by kei on Thursday, 09.25.08 @ 05:47am | #80680
there is exception as follow:
java.lang.NullPointerException
at org.hibernate.hql.antlr.HqlSqlBaseWalker.path(HqlSqlBaseWalker.java:2193)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2232)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:498)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.deleteStatement(HqlSqlBaseWalker.java:276)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:801)
at org.hibernate.impl.QueryImpl.executeUpate(QueryImpl.java:89)
at roseindia.tutorial.hibernate.DeleteHQLExample.main(DeleteHQLExample.java:27)
Posted by kei on Wednesday, 09.24.08 @ 22:20pm | #80673
I am new to Hibernate and this tutorial found it quite handy otherwise.
Posted by Anjana on Thursday, 08.14.08 @ 15:25pm | #72815
After googling a lot I found a better way to delete a record:
long contactid = 3;
Object contact = sess.load(Contact.class, contactid);
sess.delete(contact);
Posted by Anjana on Thursday, 08.14.08 @ 15:23pm | #72814
Hi
Actually above example is not woking. you have to modify code as follows
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
Transaction tx = session.beginTransaction();
List insurance = session.createSQLQuery("select * from insurance ins where Id='2'").addEntity("ins", Insurance.class).list();
Insurance insuranceObject = null;
if(it.hasNext())
{
insuranceObject = (Insurance) it.next();
System.out.println("ID: " +
ct.getLngInsuranceId());
System.out.println("Name: " + insuranceObject.getInsuranceName());
}
session.delete(insuranceObject);
tx.commit();
Posted by pramod on Wednesday, 07.30.08 @ 16:44pm | #69975
If we write down the HQL in HQL editor(in MyEclips) how to transfer it in java class
Tanks 4 all and roseindia site
Posted by manjula on Wednesday, 05.14.08 @ 14:13pm | #59784
this tut is good...keep it up
Posted by aditya on Friday, 05.9.08 @ 13:23pm | #59007
hibernate3 jar interface Query is having method 'executeUpate' and in example we are using 'executeUpdate'. And while executing Delete process I am getting exception
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
java.lang.NullPointerException
at org.hibernate.hql.antlr.HqlSqlBaseWalker.path(HqlSqlBaseWalker.java:2193)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2232)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:498)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.deleteStatement(HqlSqlBaseWalker.java:276)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:801)
at org.hibernate.impl.QueryImpl.executeUpate(QueryImpl.java:89)
at roseindia.tutorial.hibernate.DeleteHQLExample.main(DeleteHQLExample.java:23)
null
Can you please help me in this error.
Posted by Abhi on Thursday, 05.8.08 @ 12:15pm | #58891
A lots thanks to Roseindia for this tutorial, but on execution I've:
NULL
and no change in my database.
Then I've addded the "Transaction instructions" and I've changed the "hql" String in:
delete Insurance where id = 2
and on execution I've:
Hibernate: delete from INSURANCE insurance0_ where (id=2)
Exception in thread "main"
org.hibernate.exception.SQLGrammarException: could not execute update query
....
Caused by: java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'insurance0_ where (id=2)' at line 1"
Where i wrong?
Posted by magister on Thursday, 04.17.08 @ 14:35pm | #56788
this example doesn't work properly..you must use transaction..
Transaction tx = sess.beginTransaction();
tx.commit();
Posted by Magicman on Friday, 03.21.08 @ 14:14pm | #53569
HIbernate tutorial for validating a jsp form
Posted by rajesh on Wednesday, 02.20.08 @ 15:59pm | #49202
A lots thanks to Roseindia for the beginner tutorial on hibernate & swing...
Dayal
Posted by Dayal Manna on Monday, 02.18.08 @ 17:29pm | #48892
Very Good . Really its useful for me .
Posted by Asanthine S on Wednesday, 01.23.08 @ 16:26pm | #45897
good job, keep it up.thanks.
Posted by yogesh nandwana on Friday, 01.18.08 @ 18:10pm | #45522
In the above example, you will need to add-begin transaction . else it wont work.
i.e.,
Transaction tx = null;
Session session = InitSessionFactory.getInstance().openSession();
try {
tx = session.beginTransaction();
String hql = "delete from Insurance insurance where id = 2";
Query query = sess.createQuery(hql);
int row = query.executeUpdate();
Posted by Prasad Karanth on Friday, 12.7.07 @ 20:38pm | #41556
Problem: this example doesn't work and gives next error:
2007-11-21 15:43:51,527 ERROR [parser] *** ERROR: <AST>:0:0: unexpected end of subtree
2007-11-21 15:43:51,527 ERROR [parser] *** ERROR: <AST>:0:0: unexpected end of subtree
null
Posted by Vile on Wednesday, 11.21.07 @ 19:17pm | #38192
I want to delete a row from one table which has a primary key and this column is being referenced by another foreign key column in a second table.The first table has one-to-many relationship with the seond table.
Posted by Satyajit Champatiray on Thursday, 08.9.07 @ 10:45am | #22997
Please correct "Doesn't deleted any row!"
to "Didn't delete any row!"
It hurts the eyes.
Posted by Uten Qurad on Thursday, 08.2.07 @ 14:15pm | #22483