Calling stored procedures spring DAO

Posted on 2011-05-06
Medium Priority
Last Modified: 2012-05-11

I was reading folowing lines and I did not understand clearly.

Calling stored procedures
Sometimes we choose to execute our persistence operations as stored procedures
in the database rather than SQL in our application. This may be due to performance
reasons, company policy, or just a matter of taste.
Spring provides the same support for calling stored procedures as it does for executing
statements and queries. This time get the support by implementing

what it means by
>> persistence operations as stored procedures
in the database rather than SQL in our application

are the stored procedures are not SQL.

Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
Question by:gudii9
LVL 40

Accepted Solution

mrjoltcola earned 1000 total points
ID: 35709090
It means instead of your persistence layer generating dynamic SQL (insert, update, delete statements) for its persistent operations, it can make use of pre-created stored procedures for this. Some organizations do not allow dynamic SQL, but force developers to write everything "pre-compiled" as stored procedures in the database.

Assisted Solution

leticiabarbalho earned 1000 total points
ID: 35710045
The stored procedures are SQL, for course, but it think that when it says "persistence operations as stored procedures in the database rather than SQL in our application" it means SQL written directly on the source code.

You can do it both ways, and it will work in any of this ways. Example:

1 - you can write a stored procedure called listPeople with the content: "select code, name from table_people" and call it, with something like "execute listPeople" from inside your source code

2 - Inside your code, you can declare a string  with the content "select code, name from table_people" and execute this sql.

Both are SQL, but people sometimes like one rather than the other.

Some of the reasons that some people prefer option number 1, Stored Procedures, are:
- Its precompiled, like mrjoltcola said
- You can give permissions directly no the procedure object, making it safer.
- If you have a complex sql string, it will run faster, giving you better performance.

Some of the reasons people prefer option number 2, sql directly on the code, are:
- It's simpler
- You don't need a DBA permission everytime you have to change a query

If you have any more questions, feel free to ask.

If this answer helped you, please mark it as helpful on the button on the side.


Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A solution for Fortify Path Manipulation.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question