[Seasar-user:17724] Re: [dbflute-Two Tables]
kubo
[E-MAIL ADDRESS DELETED]
2009年 6月 12日 (金) 01:03:45 JST
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 メーリングリストの案内