db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Dudziak (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OJB-16) Support stored procedures in select by pk statement
Date Fri, 08 Apr 2005 19:11:17 GMT
     [ http://issues.apache.org/jira/browse/OJB-16?page=comments#action_62465 ]
     
Thomas Dudziak commented on OJB-16:
-----------------------------------

Mhmm, on the OJB level the find-by-pk and find-by-fk (or rather, find-by-some-fields) differ
only in that in the first case OJB can determine which fields to use, and in which order whereas
in the second case, the user has to specify this.
Therefore, they are alike and you can use the same format as e.g. delete-procedure uses:

<!ELEMENT delete-procedure
    (documentation?, (runtime-argument | constant-argument)*, attribute*)>

If no runtime/constant arguments were given, then OJB uses the pk fields. This mapping is
also already defined for the XDoclet tags so nothing new there. Btw, it also allows to use
constant values if one so desires.

As for what is required for the XDoclet tags, the ojb.xml file is only for documentation purposes.
If you're interested in how to add a new tag, have a look at how @ojb.delete-procedure is
handled. E.g. you need to check the .xdt files, the OjbTagsHelper class and the relevant model
objects.


> Support stored procedures in select by pk statement
> ---------------------------------------------------
>
>          Key: OJB-16
>          URL: http://issues.apache.org/jira/browse/OJB-16
>      Project: OJB
>         Type: New Feature
>   Components: PB-API
>     Versions: 1.0.x CVS
>     Reporter: Vadim Gritsenko
>  Attachments: SelectByPKProcedureDescriptor.java, db-ojb-selectbypk.diff
>
> This patch adds support for retrieving objects by primary keys through call to stored
procedure instead of using select statement.
> To activate the feature, add xdoclet tag to the class:
> /**
>  * @ojb.class table="MYBEAN"
>  * @ojb.selectbypk-procedure name="FIND_MYBEAN_BYID"
>  */
> public class MyBean {
>     /**
>      * @ojb.field primarykey="true"
>      */
>     Integer id;
> }
> And then, create stored procedure:
> CREATE OR REPLACE PACKAGE TYPES AS
>   TYPE CURSORTYPE IS REF CURSOR;
> END TYPES;
> /
> CREATE OR REPLACE FUNCTION FIND_MYBEAN_BYID (ANID IN MYBEAN.ID%TYPE)
> RETURN TYPES.CURSORTYPE AS
> RESULT TYPES.CURSORTYPE;
> BEGIN
>   OPEN RESULT FOR SELECT * FROM MYBEAN WHERE ID = ANID;
>   RETURN RESULT;
> END;
> /
> Patch is made against OJB_1_0_RELEASE branch.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message