类 MetadataSources
- java.lang.Object
-
- org.hibernate.boot.MetadataSources
-
- 所有已实现的接口:
Serializable
public class MetadataSources extends Object implements Serializable
Entry point into working with sources of metadata information (mapping XML, annotations). Tell Hibernate about sources and then callbuildMetadata(), or usegetMetadataBuilder()to customize how sources are processed (naming strategies, etc).- 从以下版本开始:
- 5.0
- 作者:
- Steve Ebersole
- 另请参阅:
- 序列化表格
-
-
构造器概要
构造器 构造器 说明 MetadataSources()MetadataSources(ServiceRegistry serviceRegistry)Create a metadata sources using the specified service registry.
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 MetadataSourcesaddAnnotatedClass(Class annotatedClass)Read metadata from the annotations attached to the given class.MetadataSourcesaddAnnotatedClassName(String annotatedClassName)Read metadata from the annotations attached to the given class.MetadataSourcesaddCacheableFile(File file)Add a cached mapping file.MetadataSourcesaddCacheableFile(String path)SeeaddCacheableFile(java.io.File)for descriptionMetadataSourcesaddCacheableFileStrictly(File file)INTENDED FOR TESTSUITE USE ONLY!MetadataSourcesaddClass(Class entityClass)已过时。hbm.xml is a legacy mapping format now considered deprecated.MetadataSourcesaddDirectory(File dir)Read all mapping documents from a directory tree.MetadataSourcesaddDocument(Document document)已过时。since 5.0.MetadataSourcesaddFile(File file)Read mappings from a particular XML fileMetadataSourcesaddFile(String path)Read mappings from a particular XML fileMetadataSourcesaddInputStream(InputStream xmlInputStream)Read metadata from anInputStream.MetadataSourcesaddInputStream(InputStreamAccess xmlInputStreamAccess)Read metadata from anInputStreamaccessMetadataSourcesaddJar(File jar)Read all mappings from a jar file.MetadataSourcesaddPackage(Package packageRef)Read package-level metadata.MetadataSourcesaddPackage(String packageName)Read package-level metadata.MetadataSourcesaddResource(String name)Read mappings as an application resourceName (i.e. classpath lookup).MetadataSourcesaddURL(URL url)Read mappings from aURLMetadatabuildMetadata()Short-hand form of callinggetMetadataBuilder()and using itsMetadataBuilder.build()method in cases where the application wants to accept the defaults.MetadatabuildMetadata(StandardServiceRegistry serviceRegistry)Collection<Class<?>>getAnnotatedClasses()Collection<String>getAnnotatedClassNames()Collection<String>getAnnotatedPackages()MetadataBuildergetMetadataBuilder()Get a builder for metadata where non-default options can be specified.MetadataBuildergetMetadataBuilder(StandardServiceRegistry serviceRegistry)已过时。UsegetMetadataBuilder()insteadServiceRegistrygetServiceRegistry()List<Binding>getXmlBindings()XmlMappingBinderAccessgetXmlMappingBinderAccess()protected static booleanisExpectedServiceRegistryType(ServiceRegistry serviceRegistry)
-
-
-
构造器详细资料
-
MetadataSources
public MetadataSources()
-
MetadataSources
public MetadataSources(ServiceRegistry serviceRegistry)
Create a metadata sources using the specified service registry.- 参数:
serviceRegistry- The service registry to use.
-
-
方法详细资料
-
isExpectedServiceRegistryType
protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry)
-
getXmlMappingBinderAccess
public XmlMappingBinderAccess getXmlMappingBinderAccess()
-
getAnnotatedPackages
public Collection<String> getAnnotatedPackages()
-
getAnnotatedClasses
public Collection<Class<?>> getAnnotatedClasses()
-
getAnnotatedClassNames
public Collection<String> getAnnotatedClassNames()
-
getServiceRegistry
public ServiceRegistry getServiceRegistry()
-
getMetadataBuilder
public MetadataBuilder getMetadataBuilder()
Get a builder for metadata where non-default options can be specified.- 返回:
- The built metadata.
-
getMetadataBuilder
@Deprecated public MetadataBuilder getMetadataBuilder(StandardServiceRegistry serviceRegistry)
已过时。UsegetMetadataBuilder()insteadGet a builder for metadata where non-default options can be specified.- 返回:
- The built metadata.
-
buildMetadata
public Metadata buildMetadata()
Short-hand form of callinggetMetadataBuilder()and using itsMetadataBuilder.build()method in cases where the application wants to accept the defaults.- 返回:
- The built metadata.
-
buildMetadata
public Metadata buildMetadata(StandardServiceRegistry serviceRegistry)
-
addAnnotatedClass
public MetadataSources addAnnotatedClass(Class annotatedClass)
Read metadata from the annotations attached to the given class.- 参数:
annotatedClass- The class containing annotations- 返回:
- this (for method chaining)
-
addAnnotatedClassName
public MetadataSources addAnnotatedClassName(String annotatedClassName)
Read metadata from the annotations attached to the given class. The important distinction here is that theClasswill not be accessed until later which is important for on-the-fly bytecode-enhancement- 参数:
annotatedClassName- The name of a class containing annotations- 返回:
- this (for method chaining)
-
addPackage
public MetadataSources addPackage(String packageName)
Read package-level metadata.- 参数:
packageName- java package name without trailing '.', cannot benull- 返回:
- this (for method chaining)
-
addPackage
public MetadataSources addPackage(Package packageRef)
Read package-level metadata.- 参数:
packageRef- Java Package reference- 返回:
- this (for method chaining)
-
addClass
@Deprecated public MetadataSources addClass(Class entityClass)
已过时。hbm.xml is a legacy mapping format now considered deprecated.Read a mapping as an application resource using the convention that a class namedfoo.bar.Foois mapped by a file namedfoo/bar/Foo.hbm.xmlwhich can be resolved as a classpath resource.- 参数:
entityClass- The mapped class. Cannot benullnull.- 返回:
- this (for method chaining purposes)
-
addResource
public MetadataSources addResource(String name)
Read mappings as an application resourceName (i.e. classpath lookup).- 参数:
name- The resource name- 返回:
- this (for method chaining purposes)
-
addFile
public MetadataSources addFile(String path)
Read mappings from a particular XML file- 参数:
path- The path to a file. Expected to be resolvable byFile(String)- 返回:
- this (for method chaining purposes)
- 另请参阅:
addFile(java.io.File)
-
addFile
public MetadataSources addFile(File file)
Read mappings from a particular XML file- 参数:
file- The reference to the XML file- 返回:
- this (for method chaining purposes)
-
addCacheableFile
public MetadataSources addCacheableFile(String path)
SeeaddCacheableFile(java.io.File)for description- 参数:
path- The path to a file. Expected to be resolvable byFile(String)- 返回:
- this (for method chaining purposes)
- 另请参阅:
addCacheableFile(java.io.File)
-
addCacheableFile
public MetadataSources addCacheableFile(File file)
Add a cached mapping file. A cached file is a serialized representation of the DOM structure of a particular mapping. It is saved from a previous call as a file with the name{xmlFile}.binwhere{xmlFile}is the name of the original mapping file. If a cached{xmlFile}.binexists and is newer than{xmlFile}, the{xmlFile}.binfile will be read directly. Otherwise{xmlFile}is read and then serialized to{xmlFile}.binfor use the next time.- 参数:
file- The cacheable mapping file to be added,{xmlFile}in above discussion.- 返回:
- this (for method chaining purposes)
-
addCacheableFileStrictly
public MetadataSources addCacheableFileStrictly(File file) throws SerializationException, FileNotFoundException
INTENDED FOR TESTSUITE USE ONLY! Much likeaddCacheableFile(java.io.File)except that here we will fail immediately if the cache version cannot be found or used for whatever reason- 参数:
file- The xml file, not the bin!- 返回:
- The dom "deserialized" from the cached file.
- 抛出:
SerializationException- Indicates a problem deserializing the cached dom treeFileNotFoundException- Indicates that the cached file was not found or was not usable.
-
addInputStream
public MetadataSources addInputStream(InputStreamAccess xmlInputStreamAccess)
Read metadata from anInputStreamaccess- 参数:
xmlInputStreamAccess- Access to an input stream containing a DOM.- 返回:
- this (for method chaining purposes)
-
addInputStream
public MetadataSources addInputStream(InputStream xmlInputStream)
Read metadata from anInputStream.- 参数:
xmlInputStream- The input stream containing a DOM.- 返回:
- this (for method chaining purposes)
-
addURL
public MetadataSources addURL(URL url)
Read mappings from aURL- 参数:
url- The url for the mapping document to be read.- 返回:
- this (for method chaining purposes)
-
addDocument
@Deprecated public MetadataSources addDocument(Document document)
已过时。since 5.0. Use one of the other methods for passing mapping source(s).Read mappings from a DOMDocument- 参数:
document- The DOM document- 返回:
- this (for method chaining purposes)
-
addJar
public MetadataSources addJar(File jar)
Read all mappings from a jar file. Assumes that any file named *.hbm.xml is a mapping document.- 参数:
jar- a jar file- 返回:
- this (for method chaining purposes)
-
addDirectory
public MetadataSources addDirectory(File dir)
Read all mapping documents from a directory tree. Assumes that any file named *.hbm.xml is a mapping document.- 参数:
dir- The directory- 返回:
- this (for method chaining purposes)
- 抛出:
MappingException- Indicates problems reading the jar file or processing the contained mapping documents.
-
-