-->
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.  [ 10 posts ] 
Author Message
 Post subject: SP output parameters - how to get their post-call values?
PostPosted: Thu Jan 12, 2006 6:38 pm 
Beginner
Beginner

Joined: Thu Jan 12, 2006 6:32 pm
Posts: 39
Location: Austin, Tx, USA, NA, Sol 3
New to Hibernate and coding is a bit confusing. We do everything via Stored Procedures; in our case, against Sybase.

I am writing code to invoke a SP (via named query) and have set the parameters. I need to get the values for the last three output parameters:

public List usersFind (String byCN, String byFirstName, String byLastName, String byEmplId,
int sqlError, int sqlRowCount, String sqlMessage) {
List lo_result = null; Query lo_query = null;

// create a new object to work with
lo_query = getSession().getNamedQuery(CS_NQ_USERS_FIND);
// set the parameters
lo_query.setString (CS_SP_PARM_USER_CN, byCN);
lo_query.setString (CS_SP_PARM_USER_FN, byFirstName);
lo_query.setString (CS_SP_PARM_USER_LN, byLastName);
lo_query.setString (CS_SP_PARM_USER_EID, byEmplId);
// output parms
lo_query.setParameter(CS_DB_SP_PARM_SQLERR, null);
lo_query.setParameter(CS_DB_SP_PARM_SQLROWCOUNT, null);
lo_query.setParameter(CS_DB_SP_PARM_SQLMSG, null);

lo_result = (List)lo_query.list();

sqlError = lo_result.get

return lo_result;
} // usersFind

and I do not see a getString or getParamter off the Query class. How does one get at these parameters?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 9:52 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Hibernate supports output parameters? I didn't know that. If I was trying to do what you are, I'd use sql-query, and specify return-scalar tags for the three return values.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 5:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
as per the docs: we dont support output parameters (yet)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: SP Support in Hibernate
PostPosted: Fri Jan 13, 2006 10:31 am 
Beginner
Beginner

Joined: Thu Jan 12, 2006 6:32 pm
Posts: 39
Location: Austin, Tx, USA, NA, Sol 3
Yet. Ah, ok. What's the time line on that? To where should I submit a request for enhancements or fixes?

We just got into the whole Java/Web environment and are investing heavily in it but after years with PowerBuilder and Sybase we find that JDBC's native support for SP's is adequate but others (like Hibernate) are horribly lacking.

The real power of a DBMS is in its SP language and we make exclusive heavy use of it, even to the point of restricting direct access to tables with the exception of text and blob fields since JDBC, and in our case Sybase, does not support those types of fields as SP parameters.

The Hibernate requirement that all SPs return a result set is as ridiculous as the statement that only the first result set will be used (the other will be discarded). That put unnecessary work on the programmer when doing detailed, mulit-sectioned reports from one SP.

I would not want to embed the SQL code necessary to do a year-end close in code when it could be handled much faster and more securely via SP code. Yes, that makes the application harder to port to other DB platforms, but the payoff is a more stable and faster application.

I can only hope that complete SP support is forthcoming at a fast pace and would be very willing to help where I can in facilitating that delivery. Should I copy this to another location?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 10:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i think you need to rethink what problem you are trying to solve with hibernate....stored procedure is not a natural fit to ORM.

But we do have support for it and it will improve, but calling it ridiculous is not very helpfull ;)

Remember that the stored procedure support is *just* for being able to return resultsets - not so much of getting single rows/values, for that raw jdbc is mostly adequate.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Security is the driving force
PostPosted: Fri Jan 13, 2006 2:37 pm 
Beginner
Beginner

Joined: Thu Jan 12, 2006 6:32 pm
Posts: 39
Location: Austin, Tx, USA, NA, Sol 3
SP's can be used for returning 1 to n rows.

SP's are the core of our data security layer here. Any ad hoc tools users may use access data via views or SP's that they have been granted access to.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 3:04 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, and ?

I'm not saying using stored procedures is bad, i'm just saying that probably not all of your stored procedures make sense to use in context of hibernate. Either of the current limitation of hibernate or the fact that the data is not really mappable by their rowish/usecase-nature

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 3:13 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
It must be a good idea to generate safe JDBC code to call stored procedures using metadata ("java.sql.DatabaseMetaData.getProcedures()"). It can be interesting for hibernate tools project too.


Quote:
class MyProdureName implements Command{

MyProdureName(Session session){
...
}

void execute(){
....... try/cacth/close stuff
}

int getMyParameter(){

...

}


void setMyParameter(int value){

...

}


}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 3:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
contributins are welcome ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 13, 2006 3:27 pm 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
I like to code eclipse plugins, probably I will find time for this stuff.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 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.