Search in sources :

Example 1 with XmlMappingBinderAccess

use of org.hibernate.boot.spi.XmlMappingBinderAccess in project hibernate-orm by hibernate.

the class CacheableHbmXmlTest method before.

@Before
public void before() throws Exception {
    ssr = new StandardServiceRegistryBuilder().build();
    binder = new XmlMappingBinderAccess(ssr).getMappingBinder();
    final URL hbmXmlUrl = getClass().getClassLoader().getResource(HBM_RESOURCE_NAME);
    if (hbmXmlUrl == null) {
        throw couldNotFindHbmXmlFile();
    }
    hbmXmlFile = new File(hbmXmlUrl.getFile());
    if (!hbmXmlFile.exists()) {
        throw couldNotFindHbmXmlFile();
    }
    hbmXmlBinFile = CacheableFileXmlSource.determineCachedFile(hbmXmlFile);
}
Also used : XmlMappingBinderAccess(org.hibernate.boot.spi.XmlMappingBinderAccess) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Example 2 with XmlMappingBinderAccess

use of org.hibernate.boot.spi.XmlMappingBinderAccess in project hibernate-orm by hibernate.

the class XmlBindingChecker method checkValidGeneration.

public static void checkValidGeneration(JaxbHbmHibernateMapping hbmMapping) throws Exception {
    JAXBContext jaxbContext = JAXBContext.newInstance(JaxbHbmHibernateMapping.class);
    Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
    jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    jaxbMarshaller.marshal(hbmMapping, bos);
    ByteArrayInputStream is = new ByteArrayInputStream(bos.toByteArray());
    ServiceRegistry sr = new StandardServiceRegistryBuilder().build();
    new XmlMappingBinderAccess(sr).bind(is);
}
Also used : Marshaller(javax.xml.bind.Marshaller) XmlMappingBinderAccess(org.hibernate.boot.spi.XmlMappingBinderAccess) StandardServiceRegistryBuilder(org.hibernate.boot.registry.StandardServiceRegistryBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) JAXBContext(javax.xml.bind.JAXBContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ServiceRegistry(org.hibernate.service.ServiceRegistry)

Aggregations

StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)2 XmlMappingBinderAccess (org.hibernate.boot.spi.XmlMappingBinderAccess)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 File (java.io.File)1 URL (java.net.URL)1 JAXBContext (javax.xml.bind.JAXBContext)1 Marshaller (javax.xml.bind.Marshaller)1 ServiceRegistry (org.hibernate.service.ServiceRegistry)1 Before (org.junit.Before)1