[Seasar-user:17903] Re: [dbflute-Two Tables]
thomas
[E-MAIL ADDRESS DELETED]
2009年 7月 2日 (木) 15:33:11 JST
Ha,
MemberCB cb = new MemberCB();
cb.setupSelect_MemberStatus();
//cb.query.setMemberId("AAA");
List<Member> memberList = memberBhv.selectList(cb);
for (Member member : memberList) {
// columns of MEMBER table
Integer memberId = member.getMemberId();
String memberName = member.getMemberName();
// columns of MEMBER_STATUS table
MemberStatus memberStatus = member.getMemberStatus(); // *Point!
String memberStatusName = memberStatus.
>
> getMemberStatusName();
> ...
> }
by using cb.query.setXXXXXX(), i can set conditions only for Member Tabel.
How can i set the condition for memberstatus table?
Is it Possible in DBFlute ConditionBean?
Thanks in advance,
トマス
2009/6/12 thomas <[E-MAIL ADDRESS DELETED]>
> Hai,
>
> Thanks for your reply...
>
> /= = = = = = = = = = = = = = = = = = = = = = = = = = = =
> MemberCB cb = new MemberCB();
> cb.setupSelect_MemberStatus(); // *Point!
>
> List<Member> memberList = memberBhv.selectList(cb);
> for (Member member : memberList) {
> // columns of MEMBER table
> Integer memberId = member.getMemberId();
> String memberName = member.getMemberName();
>
> // columns of MEMBER_STATUS table
> MemberStatus memberStatus = member.getMemberStatus(); // *Point!
> String memberStatusName = memberStatus.
>>
>> getMemberStatusName();
>> ...
>> }
>
>
>
>
> This is what i want...
>
> Thank you very much.
>
>
> Regards,
> トマス
>
>
>
>
>
>
>
> On Fri, Jun 12, 2009 at 1:03 AM, kubo <[E-MAIL ADDRESS DELETED]> wrote:
>
>> Hello,
>>
>> Sorry, it's about time for me to go to bed...
>> I can not make my reply for several hours.
>> (until next morning in Japan)
>> So I'm trying to write what I can write now.
>>
>>
>> If you want to select MEMBER and MEMBER_STATUS,
>> (MEMBER and MEMBER_STATUS : many-to-one)
>> you can implement in condition-bean like this:
>>
>> /= = = = = = = = = = = = = = = = = = = = = = = = = = = =
>> MemberCB cb = new MemberCB();
>> cb.setupSelect_MemberStatus(); // *Point!
>>
>> List<Member> memberList = memberBhv.selectList(cb);
>> for (Member member : memberList) {
>> // columns of MEMBER table
>> Integer memberId = member.getMemberId();
>> String memberName = member.getMemberName();
>>
>> // columns of MEMBER_STATUS table
>> MemberStatus memberStatus = member.getMemberStatus(); // *Point!
>> String memberStatusName = memberStatus.getMemberStatusName();
>> ...
>> }
>> - - - - - - - -
>> Please watch the method 'ConditionBeanBasicTest.test_basic_Tx()'.
>>
>> https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-basic-example/src/test/java/com/example/dbflute/basic/dbflute/howto/jp/ConditionBeanBasicTest.java
>> = = = = = = = = = =/
>>
>>
>> If you want to select MEMBER and PURCHASE,
>> (MEMBER and PURCHASE : one-to-many)
>> you can implement in condition-bean like this:
>>
>> /= = = = = = = = = = = = = = = = = = = = = = = = = = = =
>> MemberCB cb = new MemberCB();
>>
>> // At first, it selects the list of Member.
>> ListResultBean<Member> memberList = memberBhv.selectList(cb);
>>
>> // And it loads the list of Purchase with its conditions.
>> memberBhv.loadPurchaseList(memberList, new
>> ConditionBeanSetupper<PurchaseCB>() {
>> public void setup(PurchaseCB cb) {
>> cb.query().setPurchaseCount_GreaterEqual(2);
>> cb.query().addOrderBy_PurchaseCount_Desc();
>> }
>> }); // *Point!
>>
>> for (Member member : memberList) {
>> // columns of MEMBER table
>> Integer memberId = member.getMemberId();
>> String memberName = member.getMemberName();
>>
>> // list of purchase for current member.
>> List<Purchase> purchaseList = member.getPurchaseList(); // *Point!
>> for (Purchase purchase : purchaseList) {
>> // columns of Purchase table
>> Integer purchaseId = purchase.getPurchaseId();
>> ...
>> }
>> }
>> - - - - - - - -
>> Please watch the method 'BehaviorMiddleTest.test_loadReferrer_Tx()'.
>>
>> https://www.seasar.org/svn/sandbox/dbflute/trunk/dbflute-basic-example/src/test/java/com/example/dbflute/basic/dbflute/howto/jp/BehaviorMiddleTest.java
>> = = = = = = = = = =/
>>
>> On Thu, Jun 11, 2009 at 11:56 PM, kubo<[E-MAIL ADDRESS DELETED]> wrote:
>> > Hello, this is jflute
>> >
>> > I'm sorry that I can not accurately understand your question.
>> > What does it mean "more than one table"?
>> >
>> > Let me show this example database for our communication.
>> > http://dbflute.sandbox.seasar.org/view/exampledb/index.html?goto=1
>> >
>> > Does it means, for example,
>> > "MEMBER and MEMBER_STATUS"?
>> > (related two tables)
>> >
>> > select mbr.MEMBER.MEMBER_ID
>> > mbr.MEMBER.MEMBER_NAME
>> > mstat.MEMBER_STATUS_NAME
>> > from MEMBER mbr
>> > left outer join MEMBER_STATUS mstat
>> > on mbr.MEMBER_STATUS_CODE = mstat.MEMBER_STATUS_CODE
>> >
>> >
>> > 2009/6/11 thomas <[E-MAIL ADDRESS DELETED]>:
>> >> hai,
>> >>
>> >> I want to clarify one thing.
>> >> Is there any other way to select values from more than one table
>> without
>> >> using outside SQL?
>> >>
>> >> If there is any way how can i get the values from more than one table?
>> >>
>> >> Regards,
>> >> トマス
>> >>
>> >> _______________________________________________
>> >> Seasar-user mailing list
>> >> [E-MAIL ADDRESS DELETED]
>> >> https://ml.seasar.org/mailman/listinfo/seasar-user
>> >>
>> >>
>> >
>> _______________________________________________
>> Seasar-user mailing list
>> [E-MAIL ADDRESS DELETED]
>> https://ml.seasar.org/mailman/listinfo/seasar-user
>>
>
>
-------------- next part --------------
HTMLの添付ファイルを保管しました...
URL: <http://ml.seasar.org/archives/seasar-user/attachments/20090702/89cff0ae/attachment.html>
Seasar-user メーリングリストの案内