This (to me at least) feels like something that should be done in the
service layer, not in the DAO layer.
Larry
On Sat, 05 Mar 2005 09:41:13 -0500, Tak Yoshida
<[EMAIL PROTECTED]> wrote:
> Hello SQLMap development team,
>
> I would like to post this idea again,
> which is submitted to sourceforge forum last year.
>
> I believe this is not only for my case in real world,
> and makes SQLMap more flexible.
>
> I have already done on 2.0.9b, and it works pretty well on my project.
> If you would reflect my proposal in the future SQLMap, that would be great.
>
> thanks,
> Tak Yoshida
>
> -------- Here is the post on Oct 30th for 2.0.7 --------
> I found one thing I should ask,
> that is external service bean plug in feature for the complex object query.
>
> In my project, I need to use Oracle Object Cache Service for disributed
> application environment.
> and this cache will be managed outside of SQLMap framework,
> which mean I cannot use SQLMap cache plugin mechanism where SQLMap manages
> cache object itself.
>
> So I would like to have SQLMap call external service for complex object's sub
> query.
>
> Here is my proposal:
> Summary:
> Inject ServiceLocator to make SQLMap be able to call the service managed
> outside of SQLMap.
>
> 1: To make use of external object, SqlMapClient has UserServiceBeanLocator
> object property.
>
> public interface SqlMapClient extends SqlMapExecutor,
> SqlMapTransactionManager {
> public void setUserServiceBeanLocator(UserServiceBeanLocator
> serviceBeanLocator);
> public UserServiceBeanLocator getUserServiceBeanLocator();
> ....
> }
> And SqlMapClientImpl has this imlementation.
>
> public interface UserServiceBeanLocator {
> // locator method
> public Object getUserServiceBean(String name) throws SqlMapException;
> }
>
> 2: Extends resultMap's "result" tag attribute to specify the external bean
> and the method name.
>
> <result property="shipMode" column="SMODE" javaType="string"
> bean="shipModeDao" method="getShipModeById"/>
> instead of
> <result property="shipMode" column="SMODE"
> select="shipModeSqlMap.getShipModeById"/>
>
> 3: To support 2, DTD must be enhanced for new two attributes, and
> XmlSqlMapClientBuilder must support it. --> SQLMapParser on 2.0.9b
>
> 4: And to hold these external bean info in mapping object created by
> XmlSqlMapClientBuilder,
> I introduce UserServiceBeanInfo.
> public class UserServiceBeanInfo {
> private String beanName;
> private String methodName;
> private Method method;
> ...
> }
>
> 5: Utilizing aboves, BasicResultMap.getResults() method can do nested quesry
> for the complex property by calling external service.
>
> Here is a snippet of the codes
> } else if (mapping.getUserServiceBeanInfo() != null) {
> // get key for complex property
> Object rawValue = getPrimitiveResultMappingValue(rs, mapping);
> // get complex property via external service
> UserServiceBeanLocator serviceBeanLocator =
> request.getSession().getSqlMapClient().getUserServiceBeanLocator();
> UserServiceBeanInfo serviceBeanInfo = mapping.getUserServiceBeanInfo();
> try {
> Object service =
> serviceBeanLocator.getUserServiceBean(serviceBeanInfo.getBeanName());
> Method method = serviceBeanInfo.getMethod(); // check cacheed one.
> if (method == null) {
> method = service.getClass().getMethod(serviceBeanInfo.getMethodName(), new
> Class[] {mapping.getJavaType()});
> serviceBeanInfo.setMethod(method); // cache it.
> }
> columnValues[i] = method.invoke(service, new Object[] {rawValue});
> ... exception handling...
> } else {
>
> 6: Application is fully responsible to set this up at startup time.
> I am injecting spring ApplicationContext object to SqlMapClient via
> ApplicationListener,
> -------------------------------
>
> --
> Tak Yoshida mailto:[EMAIL PROTECTED]
>