Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [eclipselink-users] NamedNativeQuery, SqlResultSetMapping and left outer join

The issue is FieldResult takes the object's attribute name, not the column
name.  You must use the attribute names.

i.e.
@FieldResult(name="peopleId",      column="d_people_id"),

However, EclipseLink should probably be validating that you entered a
correct attribute name in the FieldResult, so please log a bug for this.



Andrew Wang-4 wrote:
> 
> Hi.  The original query was big, referencing 6 tables.  I created a test
> query using 2 of the tables and the same error is generated.  I'll try the
> ObjectBuildingQuery in a bit.  Here are details, thanks.
> 
> ================== PaperRequest entity =====================
> @NamedNativeQueries({
>     @NamedNativeQuery(
>         name="PaperRequest.test",
>         query="SELECT d.people_id AS d_people_id, d.sectional_cd AS
> d_sectional_cd, d.period_cd AS d_period_cd, " +
>               "       d.cit_cd AS d_cit_cd, d.delig_i AS d_delig_i, " +
>               "       d.felig_d AS d_felig_d, d.req_i AS d_req_i, " +
>               "       d.c_o_r AS d_c_o_r, " +
>               "       dw.people_id AS dw_people_id, dw.sectional_cd AS
> dw_sectional_cd, dw.period_cd AS dw_period_cd, " +
>               "       dw.cit_cd AS dw_cit_cd, dw.delig_i AS dw_delig_i, "
> +
>               "       dw.felig_d AS dw_felig_d, dw.req_i AS dw_req_i, " +
>               "       dw.c_o_r AS dw_c_o_r " +
>               "FROM isi.pap_req d " +
>               "LEFT JOIN isi.pap_req_wrk dw " +
>               "    ON d.people_id = dw.people_id AND " +
>               "       d.period_cd = dw.period_cd AND " +
>               "       d.sectional_cd = dw.sectional_cd " +
>               "WHERE d.period_cd = ? ",
>         resultSetMapping="PaperRequest.AlertTest"
>     )
> })
> @SqlResultSetMappings({
>     @SqlResultSetMapping(
>         name="PaperRequest.AlertTest",
>         entities={
>             @EntityResult(
>                 entityClass=PaperRequest.class,
>                 fields={
>                     @FieldResult(name="people_id",     
> column="d_people_id"),
>                     @FieldResult(name="sectional_cd",  
> column="d_sectional_cd"),
>                     @FieldResult(name="period_cd",     
> column="d_period_cd"),
>                     @FieldResult(name="cit_cd",        
> column="d_cit_cd"),
>                     @FieldResult(name="delig_i",       
> column="d_delig_i"),
>                     @FieldResult(name="felig_d",       
> column="d_felig_d"),
>                     @FieldResult(name="req_i",          column="d_req_i"),
>                     @FieldResult(name="c_o_r",          column="d_c_o_r")
>                 }
>             ),
>             @EntityResult(
>                 entityClass=PaperRequestWork.class,
>                 fields={
>                     @FieldResult(name="people_id",     
> column="dw_people_id"),
>                     @FieldResult(name="sectional_cd",  
> column="dw_sectional_cd"),
>                     @FieldResult(name="period_cd",     
> column="dw_period_cd"),
>                     @FieldResult(name="cit_cd",        
> column="dw_cit_cd"),
>                     @FieldResult(name="delig_i",       
> column="dw_delig_i"),
>                     @FieldResult(name="felig_d",       
> column="dw_felig_d"),
>                     @FieldResult(name="req_i",         
> column="dw_req_i"),
>                     @FieldResult(name="c_o_r",          column="dw_c_o_r")
>                 }
>             )
>         }
>     )
> })
> @Table(name = "PAP_REQ")
> @IdClass(ca.somewhere.isi.pxr.entity.conv.PaperRequestPK.class)
> public class PaperRequest extends BaseEntity implements Serializable {
>     private BigInteger peopleId;
>     @Id
>     @Column(name = "PEOPLE_ID", nullable = false, length = 10)
>     public BigInteger getPeopleId() {
>         return peopleId;
>     }
>     public void setPeopleId(BigInteger peopleId) {
>         this.peopleId = peopleId;
>     }
>     private String sectionalCode;
>     @Id
>     @Column(name = "SECTIONAL_CD", nullable = false, length = 10)
>     public String getSectionalCode() {
>         return sectionalCode;
>     }
>     private String periodCode;
>     @Id
>     @Column(name = "PERIOD_CD", nullable = false, length = 6)
>     public String getPeriodCode() {
>         return periodCode;
>     }
>     public void setPeriodCode(String periodCode) {
>         this.periodCode = periodCode;
>     }
>     // other setters and getters omitted
> 
> 


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/NamedNativeQuery%2C-SqlResultSetMapping-and-left-outer-join-tp22681230p22723805.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top