问题描述
|
我更改了代码,但问题仍然存在
CandidateResumeInfo candidateResumeInfo = new CandidateResumeInfo();
ArrayList<CandidateResumeInfo> allCandidateResumeInfo= new ArrayList<CandidateResumeInfo>();
Session session = sessionFactory.openSession();
String city1 =\"Anniston\";
Criteria crit = session.createCriteria(CandidateResumeInfo.class);
crit.createAlias(\"candidate\",\"candidateinfo\");
//crit.setFetchMode(\"candidateinfo\",FetchMode.JOIN);
crit.add( Restrictions.eq(\"candidateinfo.city\",city1));
List list = crit.list();
这是实体类..
公共类CandidateResumeInfo实现了Serializable {
...
@OneToMany
CandidateInfo candidate;
....
}
public class CandidateInfo implements Serializable{
.......
@Column(name=\"city\")
private String city;
.......
}
这是堆栈跟踪的前几行
这是一些RPC.class(在此行显示Throwable cause = e.getCause();在右侧变量侧(在调试模式下)编写了java.lang.reflect.InvocationTargetException,但是有堆栈跟踪中没有任何java.lang.reflect.InvocationTargetException
public final class RPC {
.......
public static String invokeAndEncodeResponse(Object target,Method serviceMethod,Object[] args,SerializationPolicy serializationPolicy,int flags)
throws SerializationException {
if (serviceMethod == null) {
throw new NullPointerException(\"serviceMethod\");
}
if (serializationPolicy == null) {
throw new NullPointerException(\"serializationPolicy\");
}
String responsePayload;
try {
Object result = serviceMethod.invoke(target,args);
responsePayload = encodeResponseForSuccess(serviceMethod,result,serializationPolicy,flags);
} catch (IllegalAccessException e) {
SecurityException securityException = new SecurityException(
formatIllegalAccessErrorMessage(target,serviceMethod));
securityException.initCause(e);
throw securityException;
} catch (IllegalArgumentException e) {
SecurityException securityException = new SecurityException(
formatIllegalArgumentErrorMessage(target,serviceMethod,args));
securityException.initCause(e);
throw securityException;
} catch (InvocationTargetException e) {
// Try to encode the caught exception
//
**Throwable cause = e.getCause();** // THIS IS THE LINE WHERE IT BRINGS ME ..
responsePayload = encodeResponseForFailure(serviceMethod,cause,flags);
}
解决方法
crit.createAlias(\"Class2\",\"c2\").add(Restrictions.eq(\"c2.zip\",123)
应该做...
如果仅使用\'zip \',hibernate将在类Class1中查找属性zip;它与属性是否为PK无关。