我在 JPA 中通过 createQuery 使用连接查询。我有 2 张表MasterScrip和OrderMaster。实体代码如下。动态查询正在返回集合对象。我调试了一下,发现查询执行正确,返回集合对象;但是,对象返回错误后,如下所示:
[javax.xml.bind.JAXBException: class [Ljava.lang.Object; nor any of its super class is known to this context.]
javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException...
SEVERE: Error Rendering View[/ClientTemplate/orderReport.xhtml]
javax.el.ELException: /ClientTemplate/orderReport.xhtml @14,142 value="#{stockOrderBean.scripLst}": com.sun.xml.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://service/}getOrderScripByUserNameResponse but found: {http://schemas.xmlsoap.org/soap/envelope/}Envelope
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114)
无状态bean方法:
public Collection<MasterScrip> getOrderScripByUserName(String userName)
{
try
{
String squery = "select DISTINCT(s.scripSymbol),s.scripID from MasterScrip s,OrderStock o where o.scripID.scripID = s.scripID and o.userName.userName = '" + userName + "'";
Collection<MasterScrip> c = em.createQuery(squery).getResultList();
//UserMaster um = em.find(UserMaster.class,userName);
return c;
} catch(Exception e) {
System.out.println(e);
return null;
}
}
这个错误的原因是什么?我该如何解决?