After some fiddling with the code below I suddenly get an exception telling "Transaction not successfully started." and I don't seem to get rid of it. Can you spot an error in the Java method?
Datamodel
Suggestion: suggestion_id, name, isReceivedNSD, isSetupNSD, isDecidedUHR, meeting_id, ..
Meeting: meeting_id, date
Log: log_id, suggestion_id, ..
What's special here is this:
Controlpanel: controlpanel_id, processMeeting_id (always just one row, containing current choices)
Java method
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;
}
The message is clear: Transaction not successfully started. You forgot to start the transaction:
final Transaction transaction = getSession().getTransaction();
transaction.begin();
Or simply:
final Transaction transaction = getSession().beginTransaction();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments