wood burning stoves 2.0*
The moose likes Spring and the fly likes Is HibernateCallback appropriate for executing SQL/procedures? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Is HibernateCallback appropriate for executing SQL/procedures?" Watch "Is HibernateCallback appropriate for executing SQL/procedures?" New topic
Author

Is HibernateCallback appropriate for executing SQL/procedures?

ap sharma
Greenhorn

Joined: Aug 11, 2010
Posts: 6
I'm working on a web based application that belongs to an automobil manufacturer, developed in Spring-Hibernate with MS SQL Server 2005 database.

There are three kind of use cases:

1) Through this application, end users can request for creating a Car, Bus, Truck etc through web based interfaces. When a user logs in, a HTML form gets displayed for capturing technical specification of vehicle, for ex, if someone wanted to request for Car, he can speify the Engine Make/Model, Tire, Chassis details etc and submit the form. I'm using Hibernate here for persistence, i.e. I've a Car Entity that gets saved in DB for each such request.

2) This part of the application deals with generation of reports. These reports mainly dela with number of requests received in a day and the summary. Some of the reports calculate Turnaround time for individual Create vehicle requests.

I'm using plain JDBC calls with Preparedstatement (if report can be generated with SQLs), Callablestatement (if report is complex enough and needs a DB procedure/Function to fetch all details) and HibernateCallback to execute the SQLs/Procedures and display information on screen.

3) Search: This part of application allows ensd users to search for various requests data, i.e. how many vehicle have been requested in a Year etc. I'm using DB procedure with CallableStatement..Once again executing these procedures within HibernateCallback, populating and returning search result on GUI in a POJO.

I'm using native SQL in (2) and (3) above, because for the reporting/search purpose the report data structure to display on screen is not matching with any of my Entity. For ex: Car entity has got more than 100 attributes in itself, but for reporting purpose I don't need more than 10 of them.. so i just though loading all 100 attributes does not make any sense, so why not use plain SQL and retrieve just the data needed for displaying on screen.

Similarly for Search, I had to write procedures/Functions because search algorithm is not straight forward and Hibernate has no way to write a stored procedure kind of thing.

This is working fine for proto type, however I would like to know

a. If my approach for using native SQLs and DB procedures are fine for case 2 and 3 based on my judgement.
b. Also whether executing SQLs in HibernateCallback is correct approach?

Need expert's help.

 
wood burning stoves
 
subject: Is HibernateCallback appropriate for executing SQL/procedures?
 
Similar Threads
Difference between CallableStatement and PreparedStatement
I Need tutorial calling oracle stored procedures
Calling Postgres Stored Function from EJB Session Bean
SQL Reporting Services with Java EE
ETL Warehouse Engineer - MS SQL - Cubes Newton, MA 11/17/2008