-->
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: Proessing a JDBC result set using Hibernate
PostPosted: Mon Aug 08, 2005 11:00 am 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
Guys,

I hope you can help.

We are using MSSQL server using stored proecures. Currently the stored proecudre is called using JDBC, which returns 1000 rows(say). This data is used in several places through the application, and currently I am looking at a way of applying aggregation and grouping to this stored proecdures result.

This cannot be done at the database level and might need to be donw recursively. Ie grouping on results of grouping. I have looked at Hiberante but couldnt see if this was possibel.

I have also looked ta Appache Commons etc.

Thanks for your help


Top
 Profile  
 
 Post subject: Re: Proessing a JDBC result set using Hibernate
PostPosted: Mon Aug 08, 2005 11:23 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Steve_johnson122 wrote:
Guys,

I hope you can help.

We are using MSSQL server using stored proecures. Currently the stored proecudre is called using JDBC, which returns 1000 rows(say). This data is used in several places through the application, and currently I am looking at a way of applying aggregation and grouping to this stored proecdures result.

This cannot be done at the database level and might need to be donw recursively. Ie grouping on results of grouping. I have looked at Hiberante but couldnt see if this was possibel.

I have also looked ta Appache Commons etc.

Thanks for your help


Steve,

I would suggest you do some more reading on hibernate. It is a very powerful tool in dealing with database persistence in Java.

However, if you are locked in to exectuing your stored procedure using JDBC, you will not be able to use Hibernate to populate your graph. You can however execute your Stored Procedure withint the Hibernate framework and return a graph of objects.

I would suggest looking at the Hibernate 3 reference documentation for more information.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:27 am 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
Hi,

I am not delaing with data persistence - Rather I am dealing with data retrieval.

Yes I know Hibernate can execute a stored proecure and yes i can go the hiberante way for this. However, the sored proecdeue seems to be executed only when efined in XML - a big show stopper fopr me - and even if i could execute a stored proecure using hiberante - how then can you apply filtering grouping and aggrgation to the result set.

I really dont wnat tio havbe to code this - but it looks like I might


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:30 am 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
Hi,

I am not delaing with data persistence - Rather I am dealing with data retrieval.

Yes I know Hibernate can execute a stored proecure and yes i can go the hiberante way for this. However, the sored proecdeue seems to be executed only when efined in XML - a big show stopper fopr me - and even if i could execute a stored proecure using hiberante - how then can you apply filtering grouping and aggrgation to the result set.

I really dont wnat tio havbe to code this - but it looks like I might


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:35 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Steve_johnson122 wrote:
Hi,

I am not delaing with data persistence - Rather I am dealing with data retrieval.

Yes I know Hibernate can execute a stored proecure and yes i can go the hiberante way for this. However, the sored proecdeue seems to be executed only when efined in XML - a big show stopper fopr me - and even if i could execute a stored proecure using hiberante - how then can you apply filtering grouping and aggrgation to the result set.

I really dont wnat tio havbe to code this - but it looks like I might


Your stored procedure is still defined in the database, but you have to map the return values to the class mapping in Hibernate. How else would it know what to do ?

Look at section 17.3.2 in the Hibernate 3.0.5 reference docs for an example.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:47 am 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
So if I unedrstabnd you correctly - every time a stored proecudre chnages then the XML file needs to be updated as well as your class which contain geters and setters.

This is a mainatance nightmare - JDBC allows you to process the result set regardless of how / what has retirved from the database

Does hibernate not have a generic object which you can use.

My main concern is that I do not know what the stored proecures return - they should work with any stored proecure.

Does that mean that Hibernate is definitely out the question - there is no way that I can construct the XML hibernate mapping file on the fly.

I really only need to use the power of JDBC with the nice features from Hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:47 am 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
So if I unedrstabnd you correctly - every time a stored proecudre chnages then the XML file needs to be updated as well as your class which contain geters and setters.

This is a mainatance nightmare - JDBC allows you to process the result set regardless of how / what has retirved from the database

Does hibernate not have a generic object which you can use.

My main concern is that I do not know what the stored proecures return - they should work with any stored proecure.

Does that mean that Hibernate is definitely out the question - there is no way that I can construct the XML hibernate mapping file on the fly.

I really only need to use the power of JDBC with the nice features from Hibernate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 11:53 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Steve_johnson122 wrote:
So if I unedrstabnd you correctly - every time a stored proecudre chnages then the XML file needs to be updated as well as your class which contain geters and setters.

This is a mainatance nightmare - JDBC allows you to process the result set regardless of how / what has retirved from the database

Does hibernate not have a generic object which you can use.

My main concern is that I do not know what the stored proecures return - they should work with any stored proecure.

Does that mean that Hibernate is definitely out the question - there is no way that I can construct the XML hibernate mapping file on the fly.

I really only need to use the power of JDBC with the nice features from Hibernate


How does straight JDBC help you if you change the results of your Stored Procudure ? If you add or change a column in the SP resutls, JDBC will not magically retrieve it and populate the proper field.

I obviously don't fully understand what you're doing with this data currently. But the purpose of Hibernate is to simply the process of converting database data into Java Objects. If you don't need the data in a Java object, I'm not sure what you want Hibernate to do.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 12:03 pm 
Newbie

Joined: Mon Aug 08, 2005 10:54 am
Posts: 6
Hi,

Thanks so much for your help.

Maybe let me give ou an example

public void processResultSet(String spName, int resultLength){
//open a connection to the server and exurte the stored proedcure
// Fetch each row from the result set

while (rs.next()) {
for(int i=0; i< resultLength; i++){
// Get the data from the row using the column index
String s = rs.getString(i);

// Get the data from the row using the column name
System.out.println(s);

}

}
} catch (SQLException e) {
}

This is exactly what I want - but before processign the results I want to apply a group by
or a aggregation of the data.

Is this clearer?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 08, 2005 7:40 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I don't totally understand your motivation, but perhaps you need to investigate the use of custom persisters.


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.