在摆弄下面的代码后,我突然收到一个异常,告诉我“事务未成功启动”。我似乎没有摆脱它。你能发现 Java 方法中的错误吗?
数据模型
建议:suggest_id、name、isReceivedNSD、isSetupNSD、isDecidedUHR、meeting_id、..
会议:meeting_id、日期
日志:log_id、suggest_id、..
这里的特别之处在于:
控制面板:controlpanel_id、processMeeting_id(总是只有一行,包含当前选择)
Java方法
public static List<Suggestion> getSuggestion(final int maxResults,
final boolean isReceivedNSD, final boolean isSetupNSD, final boolean isDecidedUHR,
final Status status) throws GettingException {
final Transaction transaction = getSession().getTransaction();
List<Suggestion> list = null;
final Query query;
try {
final String hql = "select f" //
+ " from Controlpanel p, Log L" //
+ " where L.suggestion.isReceivedNSD = :isReceivedNSD" //
+ " and L.suggestion.isSetupNSD = :isSetupNSD" //
+ " and L.suggestion.isDecidedUHR = :isDecidedUHR" //
+ " and L.status.id = :statusId" //
+ " and L.suggestion.meeting.id = p.processMeeting.id";
query = getSession().createQuery(hql);
query.setParameter("isReceivedNSD", isReceivedNSD);
query.setParameter("isSetupNSD", isSetupNSD);
query.setParameter("isDecidedUHR", isDecidedUHR);
query.setParameter("statusId", status.getId());
query.setMaxResults(maxResults);
list = castList(Suggestion.class, query.list());
transaction.commit();
}
catch (final HibernateException e) {
throw new GettingException("Suggestion list. " + e.getMessage());
}
finally {
HibernateCommon.rollbackIfNeededDuringHenting(transaction);
}
return list;
}