-->
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.  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: About 3.2.4 and Deprecated function
PostPosted: Tue May 15, 2007 6:39 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
This is onw of news of new hibernate version:

Deprecate the Session.connection() method, in favor of a "JDBC work" API. Schedule for removal in 4.0

So,
I used sometime this method of session object, now how i can replace it?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 8:30 am 
Beginner
Beginner

Joined: Fri Apr 22, 2005 5:58 pm
Posts: 26
I am also very interested in this, as I have some code that executes SQL directly... I simply use Hibernate to obtain my connections.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 8:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you read the javadocs. it is first in 4.0 we will remove it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 8:51 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
Thank you Mr. Max,

i read the javadoc, "To be replaced with a SPI for performing work against the connection; scheduled for removal in 4.x "

but sorry i don't understand what does "replaced with a SPI for performing work against the connection" mean?

Could some one write me any code to show me how to replace the old code "sesssion.connection()" ?

Thank you all.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 9:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
there is no direct replacement for this, but there will be in 4.0. Hence we added the deprecation warning now.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 9:09 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
AHHHHHHHHHHH!!! ok.... thank a lot... sorry now i understand :)


but a simple question, why does Hibernate team want remove this api?
Is there any problem to use directly session.connecion() ??


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 9:24 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, as soon as you call .connection() we loose control over it an cannot anymore guarantee proper connection and/or tx management.

Hence we want to provide something like the following (note that this snippet is pure pseudo code not sure if this is going to be the api):

Code:
session.doWithConnection( new JDBCAction() {
   
   public Object execute(Connection con) {
      ...do your stuff...
  }

});


This allow us to control the lifecycle of the connection.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 9:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
note, we are still pondering how we can still support the commonly used pattern of opening a session on the current session's connection...but I'm sure Steve is working on solving that :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 4:34 am 
Regular
Regular

Joined: Wed Sep 22, 2004 8:27 am
Posts: 89
really.. good.....

good developer !!!!!

thanks a lot!!!


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 16, 2007 12:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Just to clarify...

The new API will acctually start appearing in 3.3. Session.connection() will remain also, to be removed in 4.0. This gives people a chance to try and get used to the new API and gives us a chance to incorporate feedback before we actually remove Session.connection().

More than likely the API/SPI will come from parts of the work currently in the sandbox/jdbc


Top
 Profile  
 
 Post subject: improper use of @Deprecated API
PostPosted: Wed Jun 06, 2007 3:33 pm 
Newbie

Joined: Wed Jun 06, 2007 3:15 pm
Posts: 4
steve wrote:
Just to clarify...

The new API will acctually start appearing in 3.3. Session.connection() will remain also, to be removed in 4.0. This gives people a chance to try and get used to the new API and gives us a chance to incorporate feedback before we actually remove Session.connection().

More than likely the API/SPI will come from parts of the work currently in the sandbox/jdbc


FWIW, I think it is improper to deprecate a method *before* providing a reasonable alternative. From the VM spec:

"A class, interface, method, or field may be marked using a Deprecated attribute to indicate that the class, interface, method, or field has been superseded."

http://java.sun.com/docs/books/jvms/sec ... html#78232

From java.sun.com documentation on "How and When To Deprecate APIs":

"A deprecated class or method is like that. It is no longer important. It is so unimportant, in fact, that you should no longer use it, since it has been superseded and may cease to exist in the future."

http://java.sun.com/javase/6/docs/techn ... ation.html

Emphasis here on "has been superseded".

From "The Java API Document Generator":

"Adds a comment indicating that this API should no longer be used (even though it may continue to work)."

http://java.sun.com/j2se/1.5.0/docs/too ... deprecated

-sullymandias


Last edited by sullymandias on Wed Jun 06, 2007 3:51 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 3:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
so you want us to not notify our users about the problem and surprise all users when 4.x comes out ? :)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 12, 2007 11:24 am 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
I must admit I was a bit skittish myself when I saw this as we are using the raw connection in a few places, i.e. to enable tracing on the db side,etc which would fall under the umbrella of the JDBCAction semantics.

However, we are also using the raw connection to be able to spin off a fresh session piggybacked on the same connection/transaction. In some cases to look up data with different (or no) filters attached, etc.

Do you envision that will still be supported?


Top
 Profile  
 
 Post subject: yes
PostPosted: Sun Jun 17, 2007 9:03 pm 
Beginner
Beginner

Joined: Thu May 05, 2005 4:49 pm
Posts: 30
Max, precisely, you shouldn't notify users that something is deprecated if they don't have a fully working alternative that you are promoting. The right thing to do is implement your callback-style JDBCAction code in parallel with the session.connection() code in 3.3 or 4.0, allowing new users to choose the new callback-style code and allowing the old users backward-compatibility for the time being. Then in version 4.1, you can remove the session.connection() functionality.

Right now, everyone using Hibernate gets to see a deprecated warning message pop up in their build windows (and in their IDE), and we have no way to improve our code to get rid of that message. I don't feel like throwing a suppress-warnings annotation out there for the 100 or so places I'm using this code.

Connor

p.s. I didn't see the notification of the callback style in the latest API link from your website, so I had to Google around a bit before I stumbled upon this thread. Can you please document that this method is deprecated in the API for the future?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 18, 2007 1:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The session implements multiple interfaces, two of which provide the getConnection method signature. Only on, the Session interface, has the deprectaed warning applied. So you can remove the warning if you cast to the SessionImplementor interface. I am not saying this is the right approach, its just an approach. In anycase, please make sure you comment the change and when a workaround is introduced the code gets change to the new SPI.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 18 posts ]  Go to page 1, 2  Next

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.