This is my query using entity manager. Trying to join 2 table with play framework and jpa.
List<Object> joinQryResult = JPA.em().createNativeQuery(
"select e.elementname as elementname, " +
"c.comparetype as comparetype, " +
"jd.matchvalue as matchvalue " +
"from details jd " +
"join elements e on jd.elementnamerid = e.rid " +
"join comparers c on jd.comparetyperid = c.rid " +
"where jd.rid = " + temp.rid).getResultList();
Not sure how to iterate and get the values from List<Object>
I tried this
List<MyClass> myClass = (List<MyClass>)(Object)joinQryResult;
for(MyClass myC:jd)
{
System.out.println(myC.ElementName); //intellisense shows the property here
}
MyClass definition: ttrying to convert List to this type
public class MyClass {
public String ElementName;
public String CompareType;
public String MatchValue;
public JobDetails(String ElementName, String CompareType, String MatchValue)
{
this.ElementName = ElementName;
this.CompareType = CompareType;
this.MatchValue = MatchValue;
}
}
Get this error
ClassCastException occured : [Ljava.lang.Object; cannot be cast to models.MyClass
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…