wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Clarification regarding stored procedure Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Clarification regarding stored procedure Hibernate" Watch "Clarification regarding stored procedure Hibernate" New topic
Author

Clarification regarding stored procedure Hibernate

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,

I have two classes A.java and B.java in the project I use.
I have mappings for these classes.

I have a table (table C) containing only a single column (used to make the drop down in the jsp page).
This is not associated with any class A or B.
I want to call a stored procedure to get these values(select single column from table C).

Can I call the stored procedure without creating a class for this?

Thanks
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Why do you need a stored procedure for such a simple query?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Usually the users ask small changes once it is in prod. So I usually out sql in stored procedure so I dont have to redeploy for minor changes.

Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its odd to mix Hibernate, which is designed to allow your code to be transferable seemlesly accross any type of RDBMS, and stored procedures, which tightly couple you to one RDBMS. You would normally use a stored procedure from Hibernate for a piece of database logic Hibernate can't perform (e.g. create a new database user etc). You may be shooting yourself in the foot long term for a minor short term gain.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thank you.

Do you suggest I just use a named query?

Thanks
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I would just map C and access it as you would any mapped entity.
Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Thank you.
 
jQuery in Action, 2nd edition
 
subject: Clarification regarding stored procedure Hibernate
 
Similar Threads
Stored Procs Vs Direct SQL
Stored Procedure within DAO class ?
How to pass BLOB to a PL/SQL Stored Procedure
How to call stored procedure that returns an array
How to map returned cursor to a POJO / Bean in Hibernate?