Women in Technology

Hear us Roar



Article:
  Standardizing Java Persistence with the EJB3 Java Persistence API
Subject:   about dynamic query in JPA
Date:   2007-01-29 10:09:45
From:   smell
I am concern about the dynamic query in JPA. I am using IBATIS. It is a great framework, specially for dynamic query. For example:


select id="getUserFilteredPartialMember" resultClass="UserFilteredPartialMemberItem" parameterClass="UserFilterPartialMemberRequest">
SELECT MEL.FLB9S2 memberActiveInd,
MBR.ABABCD memberId,
MBR.ABAACD carrierId,
MBR.ABACCD accountId,
MBR.ABADCD groupId,
MEL.FLAECD planId,
MEL.FLAKDT planEffDt,
MBR.ABAAST gender,
MBR.ABAJDT dateOfBirth,
MEL.FLCPDA memberEffDt,
MEL.FLCQDA memberThruDt,
MBR.ABQBCD familyId,
MBR.ABOGST relationshipCode,
MBR.ABARTX firstName,
MBR.ABAQTX lastName,
MBR.ABA1TX address1,
MBR.ABA2TX address2,
MBR.ABAYTX city,
MBR.ABAZTX state,
MBR.ABA0TX zip1,
MBR.ABHKT1 zip2,
MBR.ABHLT1 zip3,
MBR.ABPZC2 country,
MBR.ABABNB phoneNumber,
MBR.ABAXTX medicareId
FROM RCMBRR01 MBR LEFT OUTER JOIN RCMELR01 MEL
ON MBR.ABABCD = MEL.FLABCD
AND MBR.ABAACD = MEL.FLAACD
AND MBR.ABACCD = MEL.FLACCD
AND MBR.ABADCD = MEL.FLADCD
WHERE 1 = 1
<isNotNull prepend="AND" property="memberId">
MBR.ABABCD $memberIdOp$ #memberId#
</isNotNull>
<isNotNull prepend="AND" property="carrierId">
MBR.ABAACD $carrierIdOp$ #carrierId#
</isNotNull>
<isNotNull prepend="AND" property="accountId">
MBR.ABACCD $accountIdOp$ #accountId#
</isNotNull>
<isNotNull prepend="AND" property="groupId">
MBR.ABADCD $groupIdOp$ #groupId#
</isNotNull>
<isNotNull prepend="AND" property="lastName">
MBR.ABAQTX $lastNameOp$ #lastName#
</isNotNull>
<isNotNull prepend="AND" property="firstName">
MBR.ABARTX $firstNameOp$ #firstName#
</isNotNull>
<isNotNull prepend="AND" property="gender">
MBR.ABAAST = #gender#
</isNotNull>
<isNotNull prepend="AND" property="dateOfBirth">
MBR.ABAJDT = #dateOfBirth#
</isNotNull>
<isNotNull prepend="AND" property="activeInd">
MEL.FLB9S2 = #activeInd#
</isNotNull>
<isNotNull prepend="AND" property="phoneNumber">
MBR.ABABNB = #phoneNumber#
</isNotNull>
<isNotNull prepend="AND" property="medicareId">
MBR.ABAXTX = #medicareId#
</isNotNull>


</select>


I am wondering whether JPA has similar functionality.


Thanks,
Joe