Example usage for org.hibernate.type BlobType BlobType

List of usage examples for org.hibernate.type BlobType BlobType

Introduction

In this page you can find the example usage for org.hibernate.type BlobType BlobType.

Prototype

public BlobType() 

Source Link

Usage

From source file:lt.emasina.resthub.server.factory.DataFactory.java

License:Open Source License

public CcData getData(final Session session, final DataHandler handler) throws Exception {
    final Query q = handler.getQuery();
    final SQLQuery query = getPagedSQLQuery(session, handler);

    for (MdColumn c : q.getColumns()) {
        switch (c.getType()) {
        case BLOB:
            query.addScalar(c.getName(), new BlobType());
            break;
        case CLOB:
            query.addScalar(c.getName(), new ClobType());
            break;
        case DATE:
            query.addScalar(c.getName(), new CalendarType());
            break;
        case NUMBER:
            query.addScalar(c.getName(), new BigDecimalType());
            break;
        case STRING:
            query.addScalar(c.getName(), new StringType());
            break;
        }//  w  w  w.  j  a  v  a 2  s.c  om
    }

    if (log.isDebugEnabled()) {
        log.debug(query.getQueryString());
    }

    ExecutorService executor = Executors.newSingleThreadExecutor();
    Future<CcData> loopRows = executor.submit(new Callable<CcData>() {

        @Override
        @SuppressWarnings("unchecked")
        public CcData call() throws Exception {
            CcData cc = new CcData();
            for (Object o : query.list()) {
                cc.addRow(q, o);
            }
            return cc;
        };
    });

    try {

        return loopRows.get(q.getTimeOut(), TimeUnit.SECONDS);

    } catch (ExecutionException | InterruptedException ex) {
        throw ex;
    } catch (TimeoutException ex) {
        throw new ServerErrorException(Status.SERVER_ERROR_GATEWAY_TIMEOUT, ex);
    }

}