Example usage for org.hibernate.internal.util.xml ErrorLogger getErrors

List of usage examples for org.hibernate.internal.util.xml ErrorLogger getErrors

Introduction

In this page you can find the example usage for org.hibernate.internal.util.xml ErrorLogger getErrors.

Prototype

public List<SAXParseException> getErrors() 

Source Link

Usage

From source file:org.beangle.orm.hibernate.internal.OverrideConfiguration.java

License:Open Source License

/**
 * Just disable xml file validation.//w w w.  j  a v  a 2 s .  co m
 */
@Override
protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException {
    try {
        ErrorLogger errorLogger = new ErrorLogger(resourceName);
        SAXReader reader = xmlHelper.createSAXReader(errorLogger, getEntityResolver());
        reader.setValidation(false);
        Document document = reader.read(new InputSource(stream));
        if (errorLogger.hasErrors()) {
            throw new MappingException("invalid configuration", errorLogger.getErrors().get(0));
        }
        doConfigure(document);
    } catch (DocumentException e) {
        throw new HibernateException("Could not parse configuration: " + resourceName, e);
    } finally {
        try {
            stream.close();
        } catch (IOException ioe) {
            logger.error("Could not close input stream for {}", resourceName);
        }
    }
    return this;
}