You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Vadim Gritsenko <va...@reverycodes.com> on 2005/05/02 16:38:25 UTC

SPs and OJB-22, Re: OJB 1.0 to 1.1 Migration Experience

Jakob Braeuchi wrote:
> hi vadim,

Hi Jacob,


> thanks for the feedback. i think we should add this to a 'migration howto'.

Yes, feel free to add it wherever :)


> btw. i commited a patch optimize the select when querying for proxies. 
> it selects the pks only. the patch does not yet support stored 
> procedures, actually i do not know if it should ?

There are situations when an application has no "direct" access to the database 
(no SELECT / UPDATE / INSERT / DELETE statements allowed), and it can use only 
stored procedures for data access. In order to be able to use OJB in such 
situations, OJB should always use stored procedure calls. For example, 
currently, if stored procedure for retrieval by fk is set, batch retrieval is 
turned off (because it uses SELECT ... WHERE ID IN (1, 2, ...) statement which 
is not trivial to do with stored procedures). So at the cost of some slowdown, 
it's possible to use OJB when "direct" database access is not allowed.


> could you please have a look at 
> SqlGeneratorDefaultImpl#getPreparedSelectPkStatement

I can suggest two ways of making it work with stored procedures:

   * Use selectByPkStatement if stored procedure is configured,
     similar to getPreparedSelectStatement:

   public String getPreparedSelectPkStatement(Query query, ClassDescriptor cld)
   {
       ProcedureDescriptor pd = cld.getSelectByFKProcedure();
       SqlStatement sql;

       if ((query instanceof QueryByExample) && (pd != null))
       {
           // Special case for QueryByExample and SelectByFKProcedure
           sql = new SqlProcedureFKStatement(pd, (QueryByExample)query, m_logger);
       }
       else
       {
           // All other queries
           sql = new SqlSelectPkStatement(m_platform, m_logger, cld, query);
       }

       return sql.getStatement();
    }


   * Add third type of procedure for selecting PKs only.
     This means you'd have to have 3 procedures per each class.


First option, AFAICS, should result in same stored procedures functionality as 
it was before the OJB-22 patch.


Regards,
Vadim


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


Re: SPs and OJB-22, Re: OJB 1.0 to 1.1 Migration Experience

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Ping?

Vadim

Vadim Gritsenko wrote:
> Jakob Braeuchi wrote:
> 
>> hi vadim,
> 
> 
> Hi Jacob,
> 
> 
>> thanks for the feedback. i think we should add this to a 'migration 
>> howto'.
> 
> 
> Yes, feel free to add it wherever :)
> 
> 
>> btw. i commited a patch optimize the select when querying for proxies. 
>> it selects the pks only. the patch does not yet support stored 
>> procedures, actually i do not know if it should ?
> 
> 
> There are situations when an application has no "direct" access to the 
> database (no SELECT / UPDATE / INSERT / DELETE statements allowed), and 
> it can use only stored procedures for data access. In order to be able 
> to use OJB in such situations, OJB should always use stored procedure 
> calls. For example, currently, if stored procedure for retrieval by fk 
> is set, batch retrieval is turned off (because it uses SELECT ... WHERE 
> ID IN (1, 2, ...) statement which is not trivial to do with stored 
> procedures). So at the cost of some slowdown, it's possible to use OJB 
> when "direct" database access is not allowed.
> 
> 
>> could you please have a look at 
>> SqlGeneratorDefaultImpl#getPreparedSelectPkStatement
> 
> 
> I can suggest two ways of making it work with stored procedures:
> 
>   * Use selectByPkStatement if stored procedure is configured,
>     similar to getPreparedSelectStatement:
> 
>   public String getPreparedSelectPkStatement(Query query, 
> ClassDescriptor cld)
>   {
>       ProcedureDescriptor pd = cld.getSelectByFKProcedure();
>       SqlStatement sql;
> 
>       if ((query instanceof QueryByExample) && (pd != null))
>       {
>           // Special case for QueryByExample and SelectByFKProcedure
>           sql = new SqlProcedureFKStatement(pd, (QueryByExample)query, 
> m_logger);
>       }
>       else
>       {
>           // All other queries
>           sql = new SqlSelectPkStatement(m_platform, m_logger, cld, query);
>       }
> 
>       return sql.getStatement();
>    }
> 
> 
>   * Add third type of procedure for selecting PKs only.
>     This means you'd have to have 3 procedures per each class.
> 
> 
> First option, AFAICS, should result in same stored procedures 
> functionality as it was before the OJB-22 patch.
> 
> 
> Regards,
> Vadim


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