Home » Eclipse Projects » EclipseLink » SQLResultSetMapping - aliases in NativeQuery not working
SQLResultSetMapping - aliases in NativeQuery not working [message #487404] |
Wed, 23 September 2009 06:50 |
Thomas Haskes Messages: 147 Registered: July 2009 |
Senior Member |
|
|
Hi,
I'm using the SQLResultSetMapping to map an entity to a nativeQuery and
found out that whenever I use aliases in the corresponding nativeQuery I
get this:
------------------------------------------------------------
Exception Description: The primary key read from the row [DatabaseRecord(
TESTRESULTMAPPING.PROP1 => null
TESTRESULTMAPPING.PROP2 => null
TESTRESULTMAPPING.PROP3 => null
TESTRESULTMAPPING.PROP4=> null)] during the execution of the query was
detected to be null. Primary keys must not contain null.
Query: ResultSetMappingQuery(referenceClass=TestResultMapping
sql="select v.col1 AS c_prop1, v.col2 as c_prop2, v.col3 as c_prop3,
v.col4 as c_prop4 from Table v")
------------------------------------------------------------ -------
As you can see it seems that the EL is not able to identify the aliases
used in the query above.
When I modify the query and the mapping not using aliases, it works.
The entity with the mapping using aliases is this:
------------------------------------------------------------ ----------
@Entity
@SqlResultSetMapping(name="TableResults",
entities = {
@EntityResult(entityClass=persistence.TestResultMapping.clas s,
fields= {
@FieldResult(name="prop1", column="c_prop1"),
@FieldResult(name="prop2", column="c_prop2"),
@FieldResult(name="prop3", column="c_prop3"),
@FieldResult(name="prop4", column="c_prop4")
})
})
public class TestResultMapping {
@Id
private String prop1;
private long prop2;
private String prop3;
private long prop4;
public String getProp1() {
return kontext;
}
public void setProp1(String prop1) {
this.prop1 = prop1;
}
... // more getters and setters
}
Query: sql="select v.col1 AS c_prop1, v.col2 as c_prop2, v.col3 as
c_prop3, v.col4 as c_prop4 from Table v")
------------------------------------------------------------ --------
The modified mapping not using aliases (that works) is this:
------------------------------------------------------------ --------
@EntityResult(entityClass=persistence.TestResultMapping.clas s,
fields= {
@FieldResult(name="prop1", column="col1"),
@FieldResult(name="prop2", column="col2"),
@FieldResult(name="prop3", column="col3"),
@FieldResult(name="prop4", column="col4")
})
})
public class TestResultMapping {
.... // like above
}
Query: sql="select v.col1 , v.col2, v.col3, v.col4 from Table v")
------------------------------------------------------------ -------
Is this a bug, or am I missing something?
Thanks in advance
Tom
|
|
| | | |
Goto Forum:
Current Time: Wed Feb 05 12:45:26 GMT 2025
Powered by FUDForum. Page generated in 0.02867 seconds
|