Search in sources :

Example 1 with JpaOrmXmlEventReader

use of org.hibernate.boot.jaxb.internal.stax.JpaOrmXmlEventReader in project hibernate-orm by hibernate.

the class MappingBinder method doBind.

@Override
protected Binding doBind(XMLEventReader staxEventReader, StartElement rootElementStartEvent, Origin origin) {
    final String rootElementLocalName = rootElementStartEvent.getName().getLocalPart();
    if ("hibernate-mapping".equals(rootElementLocalName)) {
        log.debugf("Performing JAXB binding of hbm.xml document : %s", origin.toString());
        XMLEventReader hbmReader = new HbmEventReader(staxEventReader, xmlEventFactory);
        JaxbHbmHibernateMapping hbmBindings = jaxb(hbmReader, LocalSchema.HBM.getSchema(), hbmJaxbContext(), origin);
        return new Binding<JaxbHbmHibernateMapping>(hbmBindings, origin);
    } else {
        try {
            final XMLEventReader reader = new JpaOrmXmlEventReader(staxEventReader, xmlEventFactory);
            return new Binding<Document>(toDom4jDocument(reader, origin), origin);
        } catch (JpaOrmXmlEventReader.BadVersionException e) {
            throw new UnsupportedOrmXsdVersionException(e.getRequestedVersion(), origin);
        }
    }
}
Also used : Binding(org.hibernate.boot.jaxb.spi.Binding) HbmEventReader(org.hibernate.boot.jaxb.internal.stax.HbmEventReader) XMLEventReader(javax.xml.stream.XMLEventReader) JaxbHbmHibernateMapping(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping) JpaOrmXmlEventReader(org.hibernate.boot.jaxb.internal.stax.JpaOrmXmlEventReader) UnsupportedOrmXsdVersionException(org.hibernate.boot.UnsupportedOrmXsdVersionException)

Aggregations

XMLEventReader (javax.xml.stream.XMLEventReader)1 UnsupportedOrmXsdVersionException (org.hibernate.boot.UnsupportedOrmXsdVersionException)1 JaxbHbmHibernateMapping (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping)1 HbmEventReader (org.hibernate.boot.jaxb.internal.stax.HbmEventReader)1 JpaOrmXmlEventReader (org.hibernate.boot.jaxb.internal.stax.JpaOrmXmlEventReader)1 Binding (org.hibernate.boot.jaxb.spi.Binding)1