Re: Code Generation for Stored Procedures

From: Daniel Toffetti (dtoff..ahoo.com.ar)
Date: Wed Nov 04 2009 - 15:07:07 EST

  • Next message: Michael Gentry: "Re: Code Generation for Stored Procedures"

    Michael Gentry <mgentry <at> masslight.net> writes:
    >
    > Hi Daniel,
    >
    > I'm assuming you've used the "Create Stored Procedure" button in
    > Cayenne Modeler? This doesn't actually create the stored procedure
    > itself (you can't type the SP definition into the modeler). What it
    > does is define/model a SP that you can use Cayenne to call through
    > your code. This probably isn't documented very well, but here is what
    > we currently have for calling the SP in your code:
    >
    > http://cayenne.apache.org/doc/stored-procedures.html
    >
    > mrg

        Thanks for the link, I've read it already. Ohh, now I understand,
    sorry if I wasn't clear enough.
        The stored procedures are already implemented in the database and
    the modeler retrieves them, but I was expecting some kind of code
    generation of a "dao" kind of class, think of something like this:

    public class MyCustomProcSPDAO {

        private Double outputParam;

        public Collection<ExpectedResultClass> execute(String param1,
                                                       Integer param2) {

            ProcedureQuery query = new ProcedureQuery("MyCustomProc");

            query.addParam("param1", param1);
            query.addParam("param2", param2);

            QueryResponse result = ctxt.performGenericQuery(query);

            // retrieve output parameters
            outputParam = <<...>>

            //retrieve results as a type safe collection
            Collection<ExpectedResultClass> resultCollection = <<...>>

            return resultCollection;
        }

        public Double getOutputParam() {
            return outputParam;
        }

    }

        Is this possible writing custom templates ??

    Thanks and regards,

    Daniel



    This archive was generated by hypermail 2.0.0 : Wed Nov 04 2009 - 15:08:37 EST