ひとめでConditionBean
ConditionBeanの機能
データの取得
データの取得 @Java
MemberCB cb = new MemberCB();
cb.setupSelect_MemberStatus();
cb.specify().specifyMemberStatus().columnMemberStatusName();
cb.setupSelect_MemberSecurityAsOne();
cb.setupSelect_MemberServiceAsOne().withServiceRank();
cb.setupSelect_MemberAddress(currentDate);
cb.specify().derivedMemberLoginList().max(new SubQuery<MemberLoginCB>() {
public void query(MemberLoginCB subCB) {
subCB.specify().columnLoginDatetime();
subCB.query().setMobileLoginFlg_Equal_False();
}
}, Member.ALIAS_latestLoginDatetime);
ListResultBean<Member> memberList = memberBhv.selectList(cb);
memberBhv.loadPurchase(memberList, new ConditionBeanSetupper<Pu...CB>() {
public void setup(PurchaseCB cb) {
cb.query().addOrderBy_PurchaseDatetime_Desc();
}
});
データの絞り込み
データの絞り込み @Java
...
cb.query().setMemberId_Equal(1);
cb.query().setMemberStatusCode_Equal_正式会員();
cb.query().setMemberId_NotEqual(1);
cb.query().setMemberStatusCode_NotEqual_正式会員(1);
cb.query().setMemberId_GreaterThan(3);
cb.query().setMemberId_LessThan(3);
cb.query().setMemberId_GreaterEqual(3);
cb.query().setMemberId_LessEqual(3);
cb.query().setMemberId_InScope(memberIdList);
cb.query().setMemberStatusCode_InScope_AsMemberStatus(cdefList);
cb.query().setMemberName_PrefixSearch("S");
cb.query().setMemberName_LikeSearch("vi"
, new LikeSearchOption().likeContain());
cb.query().setMemberName_LikeSearch("to vi"
, new LikeSearchOption().likeContain().splitByBlank());
cb.query().setMemberName_LikeSearch("to vi"
, new LikeSearchOption().likeContain().splitByBlank().asOrSplit());
cb.query().setBirthdate_IsNull();
cb.query().setBirthdate_IsNotNull();
cb.query().setMemo_IsNullOrEmpty();
Date fromMonth = new HandyDate("2005/10/01").getDate();
Date toMonth = new HandyDate("2005/12/01").getDate();
cb.query().setFormalizedDatetime_FromTo(fromMonth, toMonth
, new FromToOption().compareAsMonth());
Date toYear = new HandyDate("2005/01/01").getDate();
cb.query().setFormalizedDatetime_FromTo(null, toYear
, new FromToOption().compareAsYear().orIsNull());
Date fromDate = new HandyDate("2005/10/01").getDate();
Date toDate = new HandyDate("2005/10/03").getDate();
cb.query().setFormalizedDatetime_DateFromTo(fromDate, toDate);
cb.query().setMemberAge_RangeOf(30, 70, new RnageOfOption().orIsNull());
cb.query().existsPurchaseList(new SubQuery<PurchaseCB>() {
public void query(PurchaseCB subCB) {
subCB.query().setPurchasePrice_GreaterEqual(2000);
}
});
cb.query().inScopePurchaseList(new SubQuery<PurchaseCB>() {
public void query(PurchaseCB subCB) {
subCB.query().setPurchasePrice_GreaterEqual(2000);
}
});
cb.query().derivedPurchaseList().max(new SubQuery<PurchaseCB>() {
public void query(PurchaseCB subCB) {
subCB.specify().columnPurchasePrice();
subCB.query().setPaymentCompleteFlg_Equal_True();
}
}).greaterEqual(2000);
cb.query().scalar_Equal().max(new SubQuery<MemberCB>() {
public void query(MemberCB subCB) {
subCB.specify().columnBirthdate();
subCB.query().setMemberStatusCode_Equal_Formalized();
}
});
cb.query().scalar_Equal().max(new SubQuery<MemberCB>() {
public void query(MemberCB subCB) {
subCB.specify().columnBirthdate();
}
}).partitionBy(new SpecifyQuery<MemberCB>() {
public void specify(MemberCB cb) {
cb.specify().columnMemberStatusCode();
}
});
cb.query().myselfInScope(new SubQuery<MemberCB>() {
public void query(MemberCB subCB) {
subCB.query().setMemberStatusCode_Equal_Formalized();
}
});
cb.columnQuery(new SpecifyQuery<MemberCB>() {
public void specify(MemberCB cb) {
cb.specify().columnBirthdate();
}
}).lessThan(new SpecifyQuery<MemberCB>() {
public void specify(MemberCB cb) {
cb.specify().columnFormalizedDatetime();
}
});
cb.orScopeQuery(new SubQuery<MemberCB>() {
public void query(MemberCB orCB) {
orCB.query().setMemberName_PrefixSearch("S");
orCB.query().setMemberName_PrefixSearch("J");
orCB.query().setMemberId_Equal(3);
}
});
cb.orScopeQuery(new SubQuery<MemberCB>() {
public void query(MemberCB orCB) {
orCB.query().setMemberStatusCode_Equal_Withdrawal();
orCB.orScopeQueryAndPart(new AndQuery<MemberCB>() {
public void query(MemberCB andCB) {
andCB.query().setMemberId_GreaterEqual(100);
andCB.query().setFormalizedDatetime_IsNull();
}
};
}
});
cb.union(new UnionQuery<MemberCB>() {
public void query(MemberCB unionCB) {
Date targetDate = new HandyDate("2005/01/01").getDate();
unionCB.query().setBirthdate_GreaterEqual(targetDate);
}
});
...
データの並び替え
データの並び替え @Java
...
cb.query().addOrderBy_MemberId_Asc();
cb.query().addOrderBy_FormalizedDatetime_Desc();
cb.query().addOrderBy_Birthdate_Desc().withNullsFirst();
cb.query().addOrderBy_Birthdate_Desc().withNullsLast();
ManualOrderBean mob = new ManualOrderBean();
Date date24before = new HandyDate(currentDate()).addDay(-1).getDate();
mob.when_GreaterThan(date24before);
cb.query().addOrderBy_UpdateDatetime_Asc().withManualOrder(mob);
cb.query().addSpecifiedDerivedOrderBy_Desc(Member.ALIAS_latestLoginDatetime);
...
検索スタイル
検索スタイル @Java
...
int count = memberBhv.selectCount(cb);
Member member = memberBhv.selectEntity(cb);
Member member = = memberBhv.selectEntityWithDeletedCheck(cb);
ListResultBean<Member> memberList = memberBhv.selectList(cb);
PagingResultBean<Member> page = memberBhv.selectPage(cb);
Date max = memberBhv.scalarSelect(Date.class).max(new ScalarQuery<Me...CB>() {
public void query(MemberCB cb) {
cb.specify().columnBirthdate();
cb.query().setMemberStatusCode_Equal_Formalized();
}
});
memberBhv.selectCursor(cb, new EntityRowHandler<Member>() {
public void handle(Member entity) {
Integer memberId = entity.getMemberId();
String memberName = entity.getMemberName();
...
}
});
memberBhv.queryDelete(cb);
Member member = new Member();
member.setMemberStatusCode_仮会員();
memberBhv.queryUpdate(member, cb);
...
オプション
オプション @Java
...
cb.checkInvalidQuery();
cb.lockForUpdate();
...