Calling stored procedures spring DAO

Posted on 2011-05-06
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

    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

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Title # Comments Views Activity
    instanceof  operator in java 26 55
    Is there any core JDK API for PDF Creation? 5 31
    strCopies  challenge 17 60
    strDist challenge 35 69
    An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
    After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now