org.hibernate.StatelessSession.createQuery()

Here are the examples of the java api org.hibernate.StatelessSession.createQuery() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

19 Source : DefaultStreamer.java
with Apache License 2.0
from IBM

private Query<T> createQuery(StatelessSession session) {
    Query<T> compiledQuery = session.createQuery(query, type);
    setParameters(compiledQuery);
    if (maxResults > 0) {
        compiledQuery.setMaxResults(maxResults);
    }
    if (firstResult >= 0) {
        compiledQuery.setFirstResult(firstResult);
    }
    return compiledQuery;
}

12 Source : HibernateEventListener.java
with Apache License 2.0
from servicecatalog

private void removeLocalization(EnreplacedyPersister persister, Object enreplacedy) {
    if (enreplacedy instanceof DomainObject<?>) {
        DomainObject<?> obj = (DomainObject<?>) enreplacedy;
        List<LocalizedObjectTypes> objType = obj.getLocalizedObjectTypes();
        if (objType.size() > 0) {
            long key = obj.getKey();
            final StatelessSession session = persister.getFactory().openStatelessSession();
            Transaction tx = session.beginTransaction();
            org.hibernate.Query query = session.createQuery("DELETE FROM LocalizedResource WHERE objectKey = :objectKey AND objectType IN (:objectType)");
            query.setParameter("objectKey", key);
            query.setParameterList("objectType", objType);
            query.executeUpdate();
            tx.commit();
            session.close();
        }
    }
}