Example usage for org.hibernate Query setParameter

List of usage examples for org.hibernate Query setParameter

Introduction

In this page you can find the example usage for org.hibernate Query setParameter.

Prototype

@Override
    Query<R> setParameter(int position, Date value, TemporalType temporalType);

Source Link

Usage

From source file:au.edu.uts.eng.remotelabs.schedserver.rigprovider.RigProviderActivator.java

License:Open Source License

@Override
public void stop(final BundleContext context) throws Exception {
    this.logger.info("Stopping " + context.getBundle().getSymbolicName() + " bundle.");
    this.serverReg.unregister();

    /* Clean up identity tokens. */
    this.idenTokReg.unregister();
    IdentityTokenRegister.getInstance().expunge();

    this.runnableReg.unregister();

    /* Take all rigs offline. */
    Session ses = DataAccessActivator.getNewSession();
    if (ses != null) {
        Query qu = ses.createQuery("UPDATE Rig SET active=:false, in_session=:false, online=:false, "
                + "session_id=:null, offline_reason=:offline");
        qu.setBoolean("false", false);
        qu.setParameter("null", null, Hibernate.BIG_INTEGER);
        qu.setString("offline", "Scheduling Server shutting down.");

        ses.beginTransaction();/*w  ww  .  jav  a 2s  .  c  o m*/
        int num = qu.executeUpdate();
        ses.getTransaction().commit();
        this.logger.info("Took " + num + " rigs offline for shutdown.");
        ses.close();
    }

    /* Cleanup the configuration service tracker. */
    RigProviderActivator.configTracker.close();
    RigProviderActivator.configTracker = null;
}