private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { ois.defaultReadObject(); this.mapping = buildMapping(); xmlHelper = new XMLHelper(); }
public Object instantiate() { return XMLHelper.generateDom4jElement( nodeName ); }
/** * Read mappings from a <tt>String</tt> * * @param xml an XML string */ public Configuration addXML(String xml) throws MappingException { if ( log.isDebugEnabled() ) log.debug( "Mapping XML:\n" + xml ); try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( "XML String", errors, entityResolver ).read( new StringReader( xml ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); } catch ( Exception e ) { log.error( "Could not configure datastore from XML", e ); throw new MappingException( e ); } return this; }
return; XMLHelper xmlHelper = new XMLHelper(); List errors = new ArrayList(); SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
/** * Read mappings from a DOM <tt>Document</tt> * * @param doc a DOM document */ public Configuration addDocument(Document doc) throws MappingException { if ( log.isDebugEnabled() ) log.debug( "Mapping XML:\n" + doc ); try { add( xmlHelper.createDOMReader().read( doc ) ); } catch ( Exception e ) { log.error( "Could not configure datastore from XML document", e ); throw new MappingException( e ); } return this; }
/** * Read mappings from a particular XML file * * @param xmlFile a path to a file */ public Configuration addFile(String xmlFile) throws MappingException { log.info( "Mapping file: " + xmlFile ); try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( xmlFile, errors, entityResolver ).read( new File( xmlFile ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); return this; } catch ( Exception e ) { log.error( "Could not configure datastore from file: " + xmlFile, e ); throw new MappingException( "Could not configure datastore from file: " + xmlFile, e ); } }
return; XMLHelper xmlHelper = new XMLHelper(); List errors = new ArrayList(); SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
/** * Use the mappings and properties specified in the given XML document. * The format of the file is defined in * <tt>hibernate-configuration-2.2.dtd</tt>. * * @param document an XML document from which you wish to load the configuration * @return A configuration configured via the <tt>Document</tt> * @throws HibernateException if there is problem in accessing the file. */ public Configuration configure(Document document) throws HibernateException { log.info( "configuring from XML document" ); org.dom4j.Document doc; try { doc = xmlHelper.createDOMReader().read( document ); } catch ( Exception e ) { log.error( "problem parsing document", e ); throw new HibernateException( "problem parsing document", e ); } return doConfigure( doc ); }
/** * Read mappings from an <tt>InputStream</tt> * * @param xmlInputStream an <tt>InputStream</tt> containing XML */ public Configuration addInputStream(InputStream xmlInputStream) throws MappingException { try { List errors = new ArrayList(); org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, entityResolver ).read( new InputSource( xmlInputStream ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) ); add( doc ); return this; } catch ( MappingException me ) { throw me; } catch ( Exception e ) { log.error( "Could not configure datastore from input stream", e ); throw new MappingException( e ); } finally { try { xmlInputStream.close(); } catch ( IOException ioe ) { log.error( "could not close input stream", ioe ); } } }
protected void reset() { classes = new HashMap(); imports = new HashMap(); collections = new HashMap(); tables = new TreeMap(); namedQueries = new HashMap(); namedSqlQueries = new HashMap(); sqlResultSetMappings = new HashMap(); xmlHelper = new XMLHelper(); typeDefs = new HashMap(); propertyReferences = new ArrayList(); secondPasses = new ArrayList(); interceptor = EmptyInterceptor.INSTANCE; properties = Environment.getProperties(); entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER; sessionEventListenerConfig = new SessionEventListenerConfig(); filterDefinitions = new HashMap(); extendsQueue = new HashMap(); }
public Object instantiate() { return XMLHelper.generateDom4jElement(nodeName); }
try { List errors = new ArrayList(); doc = xmlHelper.createSAXReader( resourceName, errors, entityResolver ).read( new InputSource( stream ) ); if ( errors.size() != 0 ) throw new MappingException( "invalid configuration", ( Throwable ) errors.get( 0 ) );
protected void reset() { classes = new HashMap(); imports = new HashMap(); collections = new HashMap(); tables = new TreeMap(); namedQueries = new HashMap(); namedSqlQueries = new HashMap(); sqlResultSetMappings = new HashMap(); xmlHelper = new XMLHelper(); typeDefs = new HashMap(); propertyReferences = new ArrayList(); secondPasses = new ArrayList(); interceptor = EmptyInterceptor.INSTANCE; properties = Environment.getProperties(); entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER; eventListeners = new EventListeners(); filterDefinitions = new HashMap(); // extendsQueue = new ArrayList(); extendsQueue = new HashMap(); auxiliaryDatabaseObjects = new ArrayList(); tableNameBinding = new HashMap(); columnNameBindingPerTable = new HashMap(); namingStrategy = DefaultNamingStrategy.INSTANCE; sqlFunctions = new HashMap(); }
doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile ); try { log.info( "Writing cached file of " + xmlFile + " to " + lazyfile );
/** * Disable xml file validation. */ @Override protected Configuration doConfigure(InputStream stream, String resourceName) throws HibernateException { try { @SuppressWarnings("rawtypes") List errors = new ArrayList(); SAXReader reader = xmlHelper.createSAXReader(resourceName, errors, this.getEntityResolver()); reader.setValidation(false); Document document = reader.read(new InputSource(stream)); if (errors.size() != 0) { throw new MappingException("invalid configuration", (Throwable) errors.get(0)); } doConfigure(document); } catch (DocumentException e) { throw new HibernateException("Could not parse configuration: " + resourceName, e); } finally { try { stream.close(); } catch (IOException ioe) { logger.warn("could not close input stream for: " + resourceName, ioe); } } return this; }
try { List errors = new ArrayList(); SAXReader saxReader = xmlHelper.createSAXReader( "XML InputStream", errors, getEntityResolver() ); try { saxReader.setFeature( "http://apache.org/xml/features/validation/schema", true );
List errors = new ArrayList(); try { doc = xmlHelper.createSAXReader( xmlFile.getAbsolutePath(), errors, entityResolver ).read( xmlFile ); if ( errors.size() != 0 ) { throw new MappingException( "invalid mapping", ( Throwable ) errors.get( 0 ) );