my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes Unable to delete Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Unable to delete" Watch "Unable to delete" New topic
Author

Unable to delete

subhashchandra medhiassam
Ranch Hand

Joined: Sep 10, 2008
Posts: 72
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 ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336


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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3219


Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to delete