Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Check out jira issue 165 (<a href="http://jira.codehaus.org/browse/GRAILSPLUGINS-165" rel="nofollow noreferrer">http://jira.codehaus.org/browse/GRAILSPLUGINS-165</a>) There are also clues in the Quartz Plugin (which you may like to check out) This code was used with the JMS plugin which seems to work well.</p> <p>try</p> <pre><code> import org.hibernate.FlushMode import org.hibernate.Session import org.springframework.orm.hibernate3.SessionFactoryUtils import org.springframework.orm.hibernate3.SessionHolder class BatchJob implements Job, InterruptableJob { static triggers = {} void execute(JobExecutionContext context) { Session session = null; try { session = SessionFactoryUtils.getSession(sessionFactory, false); } // If not already bound the Create and Bind it! catch (java.lang.IllegalStateException ex) { session = SessionFactoryUtils.getSession(sessionFactory, true); TransactionSynchronizationManager.bindResource(sessionFactory, new SessionHolder(session)); } session.setFlushMode(FlushMode.AUTO); if( log.isDebugEnabled()) log.debug("Hibernate Session is bounded to Job thread"); // Your Code! def batch = Batch.get(context.jobDetail.jobDataMap.getLongValue("batchId")) // the next line is "line 49" from the stack trace below def foo = batch.batchStatus.description try { SessionHolder sessionHolder = (SessionHolder) TransactionSynchronizationManager.unbindResource(sessionFactory); if(!FlushMode.MANUAL.equals(sessionHolder.getSession().getFlushMode())) { sessionHolder.getSession().flush(); } SessionFactoryUtils.closeSession(sessionHolder.getSession()); if( log.isDebugEnabled()) log.debug("Hibernate Session is unbounded from Job thread and closed"); } catch (Exception ex) { ex.printStackTrace(); } } } </code></pre> <p>Hope this helps. It worked for me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload