gpt4 book ai didi

org.hibernate.cfg.annotations.reflection.XMLContext类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 23:57:05 28 4
gpt4 key购买 nike

本文整理了Java中org.hibernate.cfg.annotations.reflection.XMLContext类的一些代码示例,展示了XMLContext类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XMLContext类的具体详情如下:
包路径:org.hibernate.cfg.annotations.reflection.XMLContext
类名称:XMLContext

XMLContext介绍

[英]A helper for consuming orm.xml mappings.
[中]用于消费orm的助手。xml映射。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

public static String buildSafeClassName(String className, XMLContext.Default defaults) {
  return buildSafeClassName( className, defaults.getPackageName() );
}

代码示例来源:origin: hibernate/hibernate-orm

protected XMLContext getContext(InputStream is) throws Exception {
    XMLContext xmlContext = new XMLContext( BootstrapContextImpl.INSTANCE );
    Document doc = new SAXReader().read( is );
    xmlContext.addDocument( doc );
    return xmlContext;
  }
}

代码示例来源:origin: hibernate/hibernate-orm

globalDefaults.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
      unitElement = defaultElement.element( "access" );
      setAccess( unitElement, globalDefaults );
      unitElement = defaultElement.element( "cascade-persist" );
      globalDefaults.setCascadePersist( unitElement != null ? Boolean.TRUE : null );
      unitElement = defaultElement.element( "delimited-identifiers" );
      globalDefaults.setDelimitedIdentifiers( unitElement != null ? Boolean.TRUE : null );
      defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement, null, addedClasses ) );
entityMappingDefault.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
unitElement = root.element( "access" );
setAccess( unitElement, entityMappingDefault );
defaultElements.add( root );
setLocalAttributeConverterDefinitions( root.elements( "converter" ) );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
return addedClasses;

代码示例来源:origin: hibernate/hibernate-orm

private void addClass(List<Element> entities, String packageName, Default defaults, List<String> addedClasses) {
  for (Element element : entities) {
    String className = buildSafeClassName( element.attributeValue( "class" ), packageName );
    if ( classOverriding.containsKey( className ) ) {
      //maybe switch it to warn?
      throw new IllegalStateException( "Duplicate XML entry for " + className );
    }
    addedClasses.add( className );
    classOverriding.put( className, element );
    Default localDefault = new Default();
    localDefault.override( defaults );
    String metadataCompleteString = element.attributeValue( "metadata-complete" );
    if ( metadataCompleteString != null ) {
      localDefault.setMetadataComplete( Boolean.parseBoolean( metadataCompleteString ) );
    }
    String access = element.attributeValue( "access" );
    setAccess( access, localDefault );
    defaultsOverriding.put( className, localDefault );
    LOG.debugf( "Adding XML overriding information for %s", className );
    addEntityListenerClasses( element, packageName, addedClasses );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

if ( defaults == null ) {
  defaults = new HashMap<>();
  XMLContext.Default xmlDefaults = xmlContext.getDefault( null );
  defaults.put( "cascade-persist", xmlDefaults.getCascadePersist() );
  List<Class> entityListeners = new ArrayList<Class>();
  for ( String className : xmlContext.getDefaultEntityListeners() ) {
    try {
      entityListeners.add( classLoaderAccess.classForName( className ) );
  for ( Element element : xmlContext.getAllDocuments() ) {
    @SuppressWarnings( "unchecked" )
    List<Element> elements = element.elements( "sequence-generator" );

代码示例来源:origin: org.hibernate/hibernate-annotations

globalDefaults.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
      unitElement = defaultElement.element( "access" );
      setAccess( unitElement, globalDefaults );
      unitElement = defaultElement.element( "cascade-persist" );
      globalDefaults.setCascadePersist( unitElement != null ? Boolean.TRUE : null );
      unitElement = defaultElement.element( "delimited-identifiers" );
      globalDefaults.setDelimitedIdentifiers( unitElement != null ? Boolean.TRUE : null );
      defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement, null, addedClasses ) );
entityMappingDefault.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
unitElement = root.element( "access" );
setAccess( unitElement, entityMappingDefault );
defaultElements.add( root );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
return addedClasses;

代码示例来源:origin: hibernate/hibernate-orm

private void initAnnotations() {
  if ( annotations == null ) {
    XMLContext.Default defaults = xmlContext.getDefault( className );
    if ( className != null && propertyName == null ) {
      Element tree = xmlContext.getXMLTree( className );
      Annotation[] annotations = getPhysicalAnnotations();
      List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );
      Element tree = xmlContext.getXMLTree( className );
      Annotation[] annotations = getPhysicalAnnotations();
      List<Annotation> annotationList = new ArrayList<>( annotations.length + 5 );

代码示例来源:origin: hibernate/hibernate-orm

final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( dom4jDocument );
  for ( String className : classNames ) {
    xClasses.add( toXClass( className, reflectionManager ) );
jpaMetadataProvider.getXMLContext().applyDiscoveredAttributeConverters( attributeConverterManager );

代码示例来源:origin: hibernate/hibernate-orm

private void setAccess(Element unitElement, Default defaultType) {
  if ( unitElement != null ) {
    String access = unitElement.getTextTrim();
    setAccess( access, defaultType );
  }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public AnnotationReader getAnnotationReader(AnnotatedElement annotatedElement) {
  AnnotationReader reader = cache.get( annotatedElement );
  if (reader == null) {
    if ( xmlContext.hasContext() ) {
      reader = new JPAOverriddenAnnotationReader( annotatedElement, xmlContext, classLoaderAccess );
    }
    else {
      reader = delegate.getAnnotationReader( annotatedElement );
    }
    cache.put(annotatedElement, reader);
  }
  return reader;
}

代码示例来源:origin: org.hibernate/hibernate-annotations

final MetadataProvider metadataProvider = ( ( MetadataProviderInjector ) reflectionManager ).getMetadataProvider();
JPAMetadataProvider jpaMetadataProvider = ( JPAMetadataProvider ) metadataProvider;
List<String> classnames = jpaMetadataProvider.getXMLContext().addDocument( doc );
for ( String classname : classnames ) {
  try {

代码示例来源:origin: org.hibernate/hibernate-annotations

private void addClass(List<Element> entities, String packageName, Default defaults, List<String> addedClasses) {
  for (Element element : entities) {
    String className = buildSafeClassName( element.attributeValue( "class" ), packageName );
    if ( classOverriding.containsKey( className ) ) {
      //maybe switch it to warn?
      throw new IllegalStateException( "Duplicate XML entry for " + className );
    }
    addedClasses.add( className );
    classOverriding.put( className, element );
    Default localDefault = new Default();
    localDefault.override( defaults );
    String metadataCompleteString = element.attributeValue( "metadata-complete" );
    if ( metadataCompleteString != null ) {
      localDefault.setMetadataComplete( Boolean.parseBoolean( metadataCompleteString ) );
    }
    String access = element.attributeValue( "access" );
    setAccess( access, localDefault );
    defaultsOverriding.put( className, localDefault );
    log.debug( "Adding XML overriding information for {}", className );
    addEntityListenerClasses( element, packageName, addedClasses );
  }
}

代码示例来源:origin: org.hibernate/hibernate-annotations

public Map<Object, Object> getDefaults() {
  if ( defaults == null ) {
    defaults = new HashMap<Object, Object>();
    XMLContext.Default xmlDefaults = xmlContext.getDefault( null );
    for ( String className : xmlContext.getDefaultEntityListeners() ) {
      try {
        entityListeners.add( ReflectHelper.classForName( className, this.getClass() ) );
    for ( Element element : xmlContext.getAllDocuments() ) {
      @SuppressWarnings( "unchecked" )
      List<Element> elements = element.elements( "sequence-generator" );

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

globalDefaults.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
      unitElement = defaultElement.element( "access" );
      setAccess( unitElement, globalDefaults );
      unitElement = defaultElement.element( "cascade-persist" );
      globalDefaults.setCascadePersist( unitElement != null ? Boolean.TRUE : null );
      unitElement = defaultElement.element( "delimited-identifiers" );
      globalDefaults.setDelimitedIdentifiers( unitElement != null ? Boolean.TRUE : null );
      defaultEntityListeners.addAll( addEntityListenerClasses( defaultElement, null, addedClasses ) );
entityMappingDefault.setCatalog( unitElement != null ? unitElement.getTextTrim() : null );
unitElement = root.element( "access" );
setAccess( unitElement, entityMappingDefault );
defaultElements.add( root );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
addClass( entities, packageName, entityMappingDefault, addedClasses );
return addedClasses;

代码示例来源:origin: org.hibernate/hibernate-annotations

private void initAnnotations() {
  if ( annotations == null ) {
    XMLContext.Default defaults = xmlContext.getDefault( className );
    if ( className != null && propertyName == null ) {
      Element tree = xmlContext.getXMLTree( className );
      Annotation[] annotations = getJavaAnnotations();
      List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );
      Element tree = xmlContext.getXMLTree( className );
      Annotation[] annotations = getJavaAnnotations();
      List<Annotation> annotationList = new ArrayList<Annotation>( annotations.length + 5 );

代码示例来源:origin: org.hibernate.orm/hibernate-core

final List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( dom4jDocument );
  for ( String className : classNames ) {
    xClasses.add( toXClass( className, reflectionManager ) );
jpaMetadataProvider.getXMLContext().applyDiscoveredAttributeConverters( attributeConverterManager );

代码示例来源:origin: org.hibernate/hibernate-annotations

private void setAccess(Element unitElement, Default defaultType) {
  if ( unitElement != null ) {
    String access = unitElement.getTextTrim();
    setAccess( access, defaultType );
  }
}

代码示例来源:origin: org.hibernate/hibernate-annotations

public AnnotationReader getAnnotationReader(AnnotatedElement annotatedElement) {
  AnnotationReader reader = cache.get( annotatedElement );
  if (reader == null) {
    if ( xmlContext.hasContext() ) {
      reader = new JPAOverridenAnnotationReader( annotatedElement, xmlContext );
    }
    else {
      reader = delegate.getAnnotationReader( annotatedElement );
    }
    cache.put(annotatedElement, reader);
  }
  return reader;
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

public void add(XmlDocument metadataXml) {
  if ( inSecondPass || !isOrmXml( metadataXml ) ) {
    metadataSourceQueue.add( metadataXml );
  }
  else {
    final MetadataProvider metadataProvider = ( (MetadataProviderInjector) reflectionManager ).getMetadataProvider();
    JPAMetadataProvider jpaMetadataProvider = ( JPAMetadataProvider ) metadataProvider;
    List<String> classNames = jpaMetadataProvider.getXMLContext().addDocument( metadataXml.getDocumentTree() );
    for ( String className : classNames ) {
      try {
        metadataSourceQueue.add( reflectionManager.classForName( className, this.getClass() ) );
      }
      catch ( ClassNotFoundException e ) {
        throw new AnnotationException( "Unable to load class defined in XML: " + className, e );
      }
    }
  }
}

代码示例来源:origin: hibernate/hibernate-orm

private List<String> addEntityListenerClasses(Element element, String packageName, List<String> addedClasses) {
  List<String> localAddedClasses = new ArrayList<>();
  Element listeners = element.element( "entity-listeners" );
  if ( listeners != null ) {
    @SuppressWarnings( "unchecked" )
    List<Element> elements = listeners.elements( "entity-listener" );
    for (Element listener : elements) {
      String listenerClassName = buildSafeClassName( listener.attributeValue( "class" ), packageName );
      if ( classOverriding.containsKey( listenerClassName ) ) {
        //maybe switch it to warn?
        if ( "entity-listener".equals( classOverriding.get( listenerClassName ).getName() ) ) {
          LOG.duplicateListener( listenerClassName );
          continue;
        }
        throw new IllegalStateException("Duplicate XML entry for " + listenerClassName);
      }
      localAddedClasses.add( listenerClassName );
      classOverriding.put( listenerClassName, listener );
    }
  }
  LOG.debugf( "Adding XML overriding information for listeners: %s", localAddedClasses );
  addedClasses.addAll( localAddedClasses );
  return localAddedClasses;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com