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

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

Introduction

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

Prototype

public boolean hasErrors() 

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  av  a  2s .com
 */
@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;
}