[ http://issues.apache.org/jira/browse/OJB-16?page=comments#action_62752 ]
     
Thomas Dudziak commented on OJB-16:
-----------------------------------

> That's exactly what I proposed [1], last paragraph. But this can be
> an extension to this existing patch.

Agreed.

> by-pk can't be used if you retrieve collection - you have to query
> by non pk fields, like B.aId from example above. That's why by-fk
> was introduced. If you meant by-fk, then yes, I agree with you. If
> no collection specific SP is specified, then by-fk can be used.

Sure, but I take it from this, that by-pk is used to retrieve a reference ?

> Agreed. But that should be step 3, in three step process:
> * Implement by-pk
> * Implement by-fk
> * Implement SP per relation

I'm not so happy with the specification of by-fk at the element class level 
because it implicitly belongs to the collection. But anyway.

> It is not feasible to convert arbitrary Criteria query into SP call.
> It's possible though for query-by-example, and that's what I did in
> QueryFactory. 

I rather meant an extension to the query stuff that allows for usage of stored 
procedures instead of the sql select statement, i.e. query by criteria. But it 
may not be possible because you probably cannot specify the procedure arguments 
by name rather than by position. But was just an idea anyway.


Ok, anyway, how about calling them select-by-pk-procedure and 
select-by-fk-procedure then (for better readability) ? I can probably apply the 
patch at the weekend.
Btw, could you perhaps create some unit tests (oracle specific is ok, I can 
adapt them to PostgreSQL) ?

Tom



> 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
>     Assignee: Thomas Dudziak
>  Attachments: QueryByCriteriaBase.java, QueryByFKCriteria.java, 
> SelectByFKProcedureDescriptor.java, SelectByPKProcedureDescriptor.java, 
> SqlProcedureFKStatement.java, db-ojb-patch.diff, db-ojb-selectbypk.diff, 
> xdoclet.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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to