-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Thrown to the wolves. A simple delete of a record in the DB
PostPosted: Fri Oct 14, 2011 7:16 am 
Newbie

Joined: Fri Oct 14, 2011 6:55 am
Posts: 4
Experience with this stuff none whatsoever.
Basically thrown into the code base to support hibernate with nobody to ask questions of. So stepping through the code I can see alot of things occur but how, when, why hibernate functions how it does is beyond me at this point. Frustrated with this idea of having a technology doing something for me when a simple SQL statement would have done what I wanted weeks ago.

ISSUE:
I need to do nothing more than a simple delete from the database of a record. When trying to delete using syntax found elsewhere in the code I get "Session is closed!" exception thrown every time.

The item is independent that I want to remove meaning its not mapped as some child object inside of another object.
There are bits of code where you have something like e.g. A Paper tray object that contains paper objects, or pencil objects if the code executed to remove items is executed it updates the data just fine but, if I have a pencil object by itself and I want to remove it from the database i get that exception.

CODE:
Code:
Session hSession = HibernateUtil.getCurrentSession();
Transaction trans - hSession.beginTransaction();

From the logs It is the beginTransaction() where the exception occurs.

This code throws the Exception "Session is Closed!" what gives?

I need to get this working and have no idea where to look for the answer and if I try and spend time researching this I'm told things like do that on my own time.

Help is desperately needed.


Top
 Profile  
 
 Post subject: Re: Thrown to the wolves. A simple delete of a record in the DB
PostPosted: Fri Oct 14, 2011 7:45 am 
Newbie

Joined: Fri Oct 14, 2011 6:55 am
Posts: 4
Additionally, if I try to use the following which I saw in another page
Code:
Session hSession = HibernateUtil.getSessionFactory().getCurrentSession();


The following exception is thrown.
'No CurrentSessionContext configured!'

What I don't understand is why on the same file there are calls to update data and they function just fine without any exceptions but if I try to delete the item I get exceptions thrown.


Top
 Profile  
 
 Post subject: Re: Thrown to the wolves. A simple delete of a record in the DB
PostPosted: Mon Oct 17, 2011 9:01 am 
Newbie

Joined: Fri Oct 14, 2011 6:55 am
Posts: 4
This fixed the issue I was having. I do not know why but it did.
Code:
<property name="hibernate.current_session_context_class">thread</property>


Can anyone tell me, will this typically have a negative effect on something else?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.