本文整理了Java中org.hibernate.cfg.Configuration.add()
方法的一些代码示例,展示了Configuration.add()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.add()
方法的具体详情如下:
包路径:org.hibernate.cfg.Configuration
类名称:Configuration
方法名:add
暂无
代码示例来源:origin: org.hibernate/hibernate-annotations
private void processArtifactsOfType(ConfigurationArtefactType p) {
if ( ConfigurationArtefactType.HBM.equals( p ) ) {
log.debug( "Process hbm files" );
for ( Document document : hbmDocuments ) {
super.add( document );
}
hbmDocuments.clear();
hbmEntities.clear();
}
else if ( ConfigurationArtefactType.CLASS.equals( p ) ) {
log.debug( "Process annotated classes" );
//bind classes in the correct order calculating some inheritance state
List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses );
ExtendedMappings mappings = createExtendedMappings();
Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates(
orderedClasses, mappings
);
for ( XClass clazz : orderedClasses ) {
//todo use the same extended mapping
AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, mappings );
}
annotatedClasses.clear();
annotatedClassEntities.clear();
}
}
代码示例来源:origin: org.hibernate/hibernate-annotations
super.add( doc );
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
/**
* Read mappings from an {@link java.io.InputStream}.
*
* @param xmlInputStream The input stream containing a DOM.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the stream, or
* processing the contained mapping document.
*/
public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
add( xmlInputStream, "input stream", null );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
/**
* Read mappings from an {@link java.io.InputStream}.
*
* @param xmlInputStream The input stream containing a DOM.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the stream, or
* processing the contained mapping document.
*/
public Configuration addInputStream(InputStream xmlInputStream) throws MappingException {
add( xmlInputStream, "input stream", null );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private XmlDocument add(InputSource inputSource, Origin origin) {
XmlDocument metadataXml = MappingReader.INSTANCE.readMappingDocument( entityResolver, inputSource, origin );
add( metadataXml );
return metadataXml;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
private XmlDocument add(InputSource inputSource, Origin origin) {
XmlDocument metadataXml = MappingReader.INSTANCE.readMappingDocument( entityResolver, inputSource, origin );
add( metadataXml );
return metadataXml;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
private XmlDocument add(InputSource inputSource, String originType, String originName) {
return add( inputSource, new OriginImpl( originType, originName ) );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private XmlDocument add(InputStream inputStream, final String type, final String name) {
final InputSource inputSource = new InputSource( inputStream );
try {
return add( inputSource, type, name );
}
finally {
try {
inputStream.close();
}
catch ( IOException ignore ) {
LOG.trace( "Was unable to close input stream");
}
}
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
private XmlDocument add(InputSource inputSource, String originType, String originName) {
return add( inputSource, new OriginImpl( originType, originName ) );
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
/**
* Read mappings from a <tt>String</tt>
*
* @param xml an XML string
* @return this (for method chaining purposes)
* @throws org.hibernate.MappingException Indicates problems parsing the
* given XML string
*/
public Configuration addXML(String xml) throws MappingException {
LOG.debugf( "Mapping XML:\n%s", xml );
final InputSource inputSource = new InputSource( new StringReader( xml ) );
add( inputSource, "string", "XML String" );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
/**
* Read mappings from a <tt>String</tt>
*
* @param xml an XML string
* @return this (for method chaining purposes)
* @throws org.hibernate.MappingException Indicates problems parsing the
* given XML string
*/
public Configuration addXML(String xml) throws MappingException {
LOG.debugf( "Mapping XML:\n%s", xml );
final InputSource inputSource = new InputSource( new StringReader( xml ) );
add( inputSource, "string", "XML String" );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
private XmlDocument add(InputStream inputStream, final String type, final String name) {
final InputSource inputSource = new InputSource( inputStream );
try {
return add( inputSource, type, name );
}
finally {
try {
inputStream.close();
}
catch ( IOException ignore ) {
LOG.trace( "Was unable to close input stream");
}
}
}
代码示例来源:origin: hibernate/hibernate
/**
* 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;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
/**
* Read mappings from a <tt>URL</tt>
*
* @param url The url for the mapping document to be read.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the URL or processing
* the mapping document.
*/
public Configuration addURL(URL url) throws MappingException {
final String urlExternalForm = url.toExternalForm();
LOG.debugf( "Reading mapping document from URL : %s", urlExternalForm );
try {
add( url.openStream(), "URL", urlExternalForm );
}
catch ( IOException e ) {
throw new InvalidMappingException( "Unable to open url stream [" + urlExternalForm + "]", "URL", urlExternalForm, e );
}
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
/**
* Read mappings from a <tt>URL</tt>
*
* @param url The url for the mapping document to be read.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the URL or processing
* the mapping document.
*/
public Configuration addURL(URL url) throws MappingException {
final String urlExternalForm = url.toExternalForm();
LOG.debugf( "Reading mapping document from URL : %s", urlExternalForm );
try {
add( url.openStream(), "URL", urlExternalForm );
}
catch ( IOException e ) {
throw new InvalidMappingException( "Unable to open url stream [" + urlExternalForm + "]", "URL", urlExternalForm, e );
}
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
/**
* Read mappings as a application resource (i.e. classpath lookup).
*
* @param resourceName The resource name
* @param classLoader The class loader to use.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems locating the resource or
* processing the contained mapping document.
*/
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
LOG.readingMappingsFromResource( resourceName );
InputStream resourceInputStream = classLoader.getResourceAsStream( resourceName );
if ( resourceInputStream == null ) {
throw new MappingNotFoundException( "resource", resourceName );
}
add( resourceInputStream, "resource", resourceName );
return this;
}
代码示例来源:origin: hibernate/hibernate
/**
* 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;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
/**
* Read mappings as a application resource (i.e. classpath lookup).
*
* @param resourceName The resource name
* @param classLoader The class loader to use.
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems locating the resource or
* processing the contained mapping document.
*/
public Configuration addResource(String resourceName, ClassLoader classLoader) throws MappingException {
LOG.readingMappingsFromResource( resourceName );
InputStream resourceInputStream = classLoader.getResourceAsStream( resourceName );
if ( resourceInputStream == null ) {
throw new MappingNotFoundException( "resource", resourceName );
}
add( resourceInputStream, "resource", resourceName );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate
/**
* Read mappings from a DOM <tt>Document</tt>
*
* @param doc The DOM document
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the DOM or processing
* the mapping document.
*/
public Configuration addDocument(org.w3c.dom.Document doc) throws MappingException {
LOG.debugf( "Mapping Document:\n%s", doc );
final Document document = xmlHelper.createDOMReader().read( doc );
add( new XmlDocumentImpl( document, "unknown", null ) );
return this;
}
代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core
/**
* Read mappings from a DOM <tt>Document</tt>
*
* @param doc The DOM document
* @return this (for method chaining purposes)
* @throws MappingException Indicates problems reading the DOM or processing
* the mapping document.
*/
public Configuration addDocument(org.w3c.dom.Document doc) throws MappingException {
LOG.debugf( "Mapping Document:\n%s", doc );
final Document document = xmlHelper.createDOMReader().read( doc );
add( new XmlDocumentImpl( document, "unknown", null ) );
return this;
}
内容来源于网络,如有侵权,请联系作者删除!