Results 1 to 7 of 7

Thread: execute methods of StoredProcedure

  1. #1
    Join Date
    Nov 2007
    Posts
    4

    Default execute methods of StoredProcedure

    Hello!
    Could u tell me why execute methods of Stored Procedure are public?
    I think that they should be protected, because they should be used only by subclasses. Also subclass cannot make it invisible (protected or private). If they were protected, subclass would make it public if it needs to.
    Thanks

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Why? That way you would always need to provide your own execute method, while it could be perfectly fine to use the normal execute method.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Nov 2007
    Posts
    4

    Default

    Quote Originally Posted by mdeinum View Post
    Why? That way you would always need to provide your own execute method, while it could be perfectly fine to use the normal execute method.
    It said in JavaDocs:
    "This class is abstract and it is intended that subclasses will provide a typed method for invocation that delegates to the supplied execute(java.util.Map) method."
    I believe it is how StoredProcedure used.
    The need to provide execute method doesnt' depend on whether it is protected or public. Even more if it is protected you should provide it otherwise clients whould have no methods to invoke.
    Last edited by wadissimo; Nov 26th, 2007 at 06:23 AM.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    Hmm we have quite some classes which extend the StoredProcedure class, we use it with the supplied execute method. If the method would become protected, we would need to rewrite part of our application.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Nov 2007
    Posts
    4

    Default

    But now we need to always use super.execute() and override execute() and throw RuntimeException from it.=(

  6. #6
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    But now we need to always use super.execute() and override execute() and throw RuntimeException from it.=(
    Why? If I have an instance of StoredProcedure (be it an extension or anonymous inner class) I can simply call execute and pass in a map.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  7. #7
    Join Date
    Nov 2007
    Posts
    4

    Default

    I understand ur point. But we don't need to expose this method.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •