Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarification regarding stored procedure Hibernate

 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need a stored procedure for such a simple query?

Mark
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

Do you suggest I just use a named query?

Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would just map C and access it as you would any mapped entity.
 
Justin Howard
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic