[ http://issues.apache.org/jira/browse/OJB-16?page=comments#action_62751 ]
     
Vadim Gritsenko commented on OJB-16:
------------------------------------

> Ok, so you can at most specify two procedures,
> one by-pk and one by-fk, at class level ?!

Yes. Additionally, you can specify update-, delete-, insert- procedures: also 
only one of each, at most, at the class level.


> Hmm, WDYT, wouldn't it make more sense to specify the by-fk at the
> collection/reference rather than the class ? This way, you could
> use different procedures,

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


> and per default the by-pk would be used
> (i.e. the current handling which matches fk field values against the
> corresponding pks).

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.


> Then you don't have any name problem, and the retrieval is way more
> flexible.

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

Where first two steps provide simple yet generic implementation, while step 3 
provides more complex but flexible implementation. I don't see why OJB can't 
have all three implemented.


> As for queries, IMO it would make sense to generally allow the
> specification of a stored procedure to be used for retrieval whenever
> a select would be issued. But I'm no expert in the query stuff.

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.

Vadim

[1] http://issues.apache.org/jira/browse/OJB-16#action_62501


> 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