1
我改變了代碼,但問題仍然存在FetchMode只有主鍵列工作
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,但在堆棧跟蹤
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,
serializationPolicy, flags);
}
謝謝,我已經改變了代碼,因爲你說,仍然沒有解決,請審查上面的代碼(我粘貼了實際的代碼),並讓我知道如果我做了一些事情錯了謝謝 – junaidp 2011-05-30 09:01:59
'crit.createAlias 「CandidateInfo」...);'如果你的財產被稱爲候選人,這應該是'crit.createAlias(「候選人」,...' – 2011-05-30 09:14:59
改變了它,也在上面編輯,問題仍然存在,任何建議。謝謝 – junaidp 2011-05-30 09:49:37