Hibernate chokes on this HQL cross join

Thor Hovden

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;
}
JB Nizet

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Hibernate HQL: Left Join with OnetoOne

From Dev

Hibernate HQL: is JOIN really necessary?

From Dev

Hibernate HQL join fetch not recursively fetching

From Dev

Hibernate fetch=join/select is not applicable for HQL?

From Dev

Hibernate HQl to join two level tables

From Dev

How to query join one to many in hibernate HQL

From Dev

HQL implicit join in where clause generate cross join instead of inner join

From Dev

Hibernate HQL bulk delete don't remove join table values

From Dev

Hibernate: HQL join query on association doesnt result as expected

From Dev

Hibernate LEFT JOIN HQL query not counting correctly with condition

From Dev

Hibernate HQL bulk delete don't remove join table values

From Dev

Hibernate: HQL join query on association doesnt result as expected

From Dev

Hibernate HQL from child to parent table using left join

From Dev

Why does Hibernate generate a CROSS JOIN for an implicit join of a @ManyToOne association?

From Dev

Unexpected Cross Join Generated SQL Using EntityManager with hibernate

From Dev

Why hibernate add to my query cross join at the end

From Dev

Using JPQL(not HQL) with Hibernate

From Dev

Configuring Hibernate for HQL

From Dev

hibernate HQL Query select

From Dev

HQL Hibernate many tables

From Dev

Hibernate: HQL is not working

From Dev

Hibernate - HQL parameters passing

From Dev

Hibernate HQL injection example

From Dev

HQL right outer join

From Dev

Join statement on HQL

From Dev

hql join with @CollectionTable

From Dev

HQL join on another table

From Dev

HQL join unexpected token

From Dev

hibernate fetch lazy: Initialize() or HQL