[seasar-dotnet:2140] Re: [S2Dxo]DxoExceptionが発生する

kubo [E-MAIL ADDRESS DELETED]
2012年 4月 2日 (月) 23:22:14 JST


久保(jflute)です。

寺嶋さん、こんばんは

ちょっとDxoに関しては、ちょっと細かく助言できないのですが、
DBFluteとしてのポリシーとしては、Dxoの利用はお奨めしていません。
なぜなら、DBFluteではカラム名の変更や削除などに対応できるよう、
CBなどでタイプセーフに自動生成と色々やっているのに、
(外だしSQLも2WaySQLの一括実行ですぐに検知できるように)
Dxoのようなリフレクションではそれが検知できなくなってしまうからです。

そして久保個人のポリシーとしては、
ここ何年も、関わる多くのプロジェクトでDxoのようにリフレクションを
使って詰め替えをやらないようにアドバイスをしています。
DB変更にどうのこうのというのに加えて、実際にそれで原因を掴みにくい
やっかいなトラブルが発生したプロジェクトを何度も見たからです。
10分くらいのGet/Set実装をはしょって、後の不思議なトラブルの
可能性を高くすることはない、という考え方です。

とはいえ、既に利用しているのであれば、しっかりと使えた方が
いいと思うので、どなたかDxoに詳しい方、助言頂ければと。

2012/4/2 寺嶋 千晴 <[E-MAIL ADDRESS DELETED]>:
> お世話になっております。寺嶋です。
>
> 先日はDBFluteの対応をして頂きありがとうございました。
> 大変助かりました。今後ともよろしくお願い致します。
> 今回はS2Dxo.netについて教えていただきたいことがあり、投稿させて頂きました。
>
> DBFluteで検索した結果をS2Dxo.netを利用してDTOにコピーするとDxoExceptionが
> 発生する現象が起きてしまっています。
>
> 発生条件としましては、コピー元にList型プロパティがあり(件数は0件)、コピー先に
> 同じ名前のプロパティが存在しないと発生します。
> コピー元のList型プロパティがNullですと発生しないのですが、件数が0件であっても
> 同じ動きとしたいのですがどのように対処すればよろしいでしょうか?
> 皆様お忙しい中、お手数をお掛け致しますが何か情報があればご教授ください。
>
> ------- エラー内容 -------
> [TargetParameterCountException: パラメーター カウントが一致しません。]
>   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +9348302
>   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +28
>   System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) +63
>   System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index) +19
>   Seasar.Dxo.Interceptor.DxoInterceptor._TryExchangeSameNameProperty(PropertyInfo sourceInfo, Object source, Object dest, Type destType, Int32 cnt) +460
>
> [DxoException: パラメーター カウントが一致しません。]
>   Seasar.Dxo.Interceptor.DxoInterceptor._TryExchangeSameNameProperty(PropertyInfo sourceInfo, Object source, Object dest, Type destType, Int32 cnt) +952
>   Seasar.Dxo.Interceptor.DxoInterceptor.AssignTo(Object source, Object dest, Int32 cnt) +185
>   Seasar.Dxo.Interceptor.DxoInterceptor._TryExchangeSameNameProperty(PropertyInfo sourceInfo, Object source, Object dest, Type destType, Int32 cnt) +566
>
> [DxoException: パラメーター カウントが一致しません。]
>   Seasar.Dxo.Interceptor.DxoInterceptor._TryExchangeSameNameProperty(PropertyInfo sourceInfo, Object source, Object dest, Type destType, Int32 cnt) +952
>   Seasar.Dxo.Interceptor.DxoInterceptor.AssignTo(Object source, Object dest, Int32 cnt) +185
>   Seasar.Dxo.Interceptor.DxoInterceptor.Invoke(IMethodInvocation invocation) +1863
>   Seasar.Framework.Aop.Impl.InterceptorAdapter.Intercept(IInvocation invocation) +222
>   Castle.DynamicProxy.AbstractInvocation.Proceed() +462
>   Castle.Proxies.ITestDxoProxy.ConvertToPageBean(ABean aBean) +152
>   WebApplication1._Default.Page_Load(Object sender, EventArgs e) in C:\Users\cterash\Documents\Visual Studio 2010\Projects\WebApplication1\WebApplication1\Default.aspx.cs:28
>   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
>   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
>   System.Web.UI.Control.OnLoad(EventArgs e) +91
>   System.Web.UI.Control.LoadRecursive() +74
>   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
>
>
>
> ------- サンプルソース(呼び元) -------
>    public partial class _Default : System.Web.UI.Page {
>        protected ITestDxo iTestDxo;
>        protected void Page_Load(object sender, EventArgs e) {
>            QuillInjector.GetInstance().Inject(this);
>            ABean aBean = new ABean();
>            aBean.Hoge = "hoge";
>            // ↓をコメントにするとExceptionは発生しない
>            aBean.HogeList = new List<string>();
>
>            BBean bBean = iTestDxo.ConvertToPageBean(aBean);
>        }
>    }
>
> ------- サンプルソース(ITestDxo) -------
>    [Implementation]
>    [Aspect(typeof(DxoInterceptor))]
>    public interface ITestDxo {
>        BBean ConvertToPageBean(ABean aBean);
>    }
>
> ------- サンプルソース(ABean) -------
>    public class ABean {
>        private string hoge;
>        public string Hoge {
>            get { return hoge; }
>            set { hoge = value; }
>        }
>        private List<string> hogeList;
>        public List<string> HogeList {
>            get { return hogeList; }
>            set { hogeList = value; }
>        }
>    }
>
> ------- サンプルソース(BBean) -------
>    public class BBean {
>        private string hoge;
>        public string Hoge {
>            get { return hoge; }
>            set { hoge = value; }
>        }
>    }
> _______________________________________________
> seasar-dotnet mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-dotnet


seasar-dotnet メーリングリストの案内