• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Unable to delete

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
I have a table named Contact in mysql running on localhost. The columns in the table are ID,FIRSTNAME, LASTNAME and EMAIL.
There's only one row in the table. The values in the row are ID = 6, FIRSTNAME = Subhash, LASTNAME = Medhi and EMAIL = subhash.chandra.medhi@xyz.com .

I am using the following code to delete this row:



if i execute this code, the row doesn't get deleted and i get the following output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
null


if use try-catch statement around "row = query.executeUpate();" in the following way:



the row doesn't get deleted, and i get the following output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
null
Couldn't delete any row!

Kindly do let me know where i might have gone wrong.

[ Edited to use code tags - Paul Sturrock ]
[ September 11, 2008: Message edited by: Paul Sturrock ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
null


This output is log4j telling you you have not configured your loggers correctly. Nothing to do with Hibenrtae itself. I'd double check what you've got in log4j.properties and where it is.

Your code is assuming Hibernate is working "non-transationally" i.e. there either are no transactions involved, or if there are they are auto-commiting. Auto-commit is disabled by default in Hibernate, so unless you have configured it otherwise you'll need to wrap your operation in a transaction and commit it at the end. See this.
[ September 11, 2008: Message edited by: Paul Sturrock ]
 
Author
Posts: 3473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Throw this in your log4j.properties file, and you should get rid of the warnings:

http://ideoplex.com/id/386/controlling-hibernate-output-with-log4j



-Cameron McKenzie
[ September 11, 2008: Message edited by: Cameron Wallace McKenzie ]
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic