Example usage for org.hibernate.criterion Projection getAliases

List of usage examples for org.hibernate.criterion Projection getAliases

Introduction

In this page you can find the example usage for org.hibernate.criterion Projection getAliases.

Prototype

public String[] getAliases();

Source Link

Document

Get the criteria-level aliases for this projection (ie.

Usage

From source file:com.heliosapm.aa4h.parser.XMLQueryParser.java

License:Apache License

/**
 * End Document SAX ContentHandler Method.
 * Fired at the end of the document parsing event.
 * At this point the query has been fully parsed and the named or criteria query is complete.
 * This method executes the query and sets the result field, handling any errors.
 * @see org.xml.sax.ContentHandler#endDocument()
 * @throws SAXException/* w w  w  .j  a  va 2s. c  o  m*/
 * TODO Clean up the timeout handling. The current one is Oracle specific. We need the timeout handling to differentiate between standard DB Errors and timeouts as a result of a user requested timeout.
 */
@SuppressWarnings("unchecked")
public void endDocument() throws SAXException {
    parseTime = System.currentTimeMillis() - parseTime;
    try {
        if (isNamedQuery) {
            result = query.list();
        } else {
            Criteria finalCriteria = (Criteria) criteriaStack.pop();

            Projection p = ((CriteriaImpl) finalCriteria).getProjection();
            if (p != null) {
                aliases = p.getAliases();
            }
            result = finalCriteria.list();
        }
    } catch (Exception ex) {
        try {
            if (ex.getCause().getMessage().startsWith("ORA-01013")) {
                toe = new TimeoutException("Query " + queryName + " Timed Out");
                QName q = new QName("Error");
                DefaultElement de = new DefaultElement(q);
                de.addAttribute("reason", "Query Time Out");
                result = new ArrayList<DefaultElement>();
                result.add(de);
                endTime = System.currentTimeMillis();

            } else {
                throw new SAXException("Unknown Exception At List Time for Query:" + queryName, ex);
            }
        } catch (Exception e) {
            log.error("Unknown Exception At List Time for Query:" + queryName, ex);
            throw new SAXException("Unknown Exception At List Time for Query:" + queryName, ex);
        }

    }
    endTime = System.currentTimeMillis();
    if (log.isDebugEnabled()) {
        log.info(new StringBuffer("CATSQuery[").append(queryName).append("] Returned ").append(result.size())
                .append(" elements in ").append((endTime - startTime)).append(" ms.").toString());
        log.info("Elapsed Time For [" + queryName + "]:" + (endTime - startTime) + " ms.");
    }

}