org.hibernate.cfg.Configuration.createMappings()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(116)

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

Configuration.createMappings介绍

[英]Create a new Mappings to add class and collection mappings to.
[中]创建新的映射以将类和集合映射添加到。

代码示例

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

protected void add(org.dom4j.Document doc) throws MappingException {
  try {
    HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP ); // TODO: possibly get inheritable meta's from cfg.xml
  }
  catch ( MappingException me ) {
    log.error( "Could not compile the mapping document", me );
    throw me;
  }
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

protected void add(org.dom4j.Document doc) throws MappingException {
  HbmBinder.bindRoot( doc, createMappings(), CollectionHelper.EMPTY_MAP );
}

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

private void processAnnotatedClassesQueue() {
  LOG.debug( "Process annotated classes" );
  //bind classes in the correct order calculating some inheritance state
  List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses );
  Mappings mappings = createMappings();
  Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates(
      orderedClasses, mappings
  );
  for ( XClass clazz : orderedClasses ) {
    AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, mappings );
    final String entityName = clazz.getName();
    if ( hbmMetadataByEntityNameXRef.containsKey( entityName ) ) {
      hbmMetadataToEntityNamesMap.remove( hbmMetadataByEntityNameXRef.get( entityName ) );
      hbmMetadataByEntityNameXRef.remove( entityName );
    }
  }
  annotatedClasses.clear();
  annotatedClassesByEntityNameMap.clear();
}

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

private void processAnnotatedClassesQueue() {
  LOG.debug( "Process annotated classes" );
  //bind classes in the correct order calculating some inheritance state
  List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses );
  Mappings mappings = createMappings();
  Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates(
      orderedClasses, mappings
  );
  for ( XClass clazz : orderedClasses ) {
    AnnotationBinder.bindClass( clazz, inheritanceStatePerClass, mappings );
    final String entityName = clazz.getName();
    if ( hbmMetadataByEntityNameXRef.containsKey( entityName ) ) {
      hbmMetadataToEntityNamesMap.remove( hbmMetadataByEntityNameXRef.get( entityName ) );
      hbmMetadataByEntityNameXRef.remove( entityName );
    }
  }
  annotatedClasses.clear();
  annotatedClassesByEntityNameMap.clear();
}

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

private void processHbmXml(XmlDocument metadataXml, Set<String> entityNames) {
  try {
    HbmBinder.bindRoot( metadataXml, createMappings(), CollectionHelper.EMPTY_MAP, entityNames );
  }
  catch ( MappingException me ) {
    throw new InvalidMappingException(
        metadataXml.getOrigin().getType(),
        metadataXml.getOrigin().getName(),
        me
    );
  }
  for ( String entityName : entityNames ) {
    if ( annotatedClassesByEntityNameMap.containsKey( entityName ) ) {
      annotatedClasses.remove( annotatedClassesByEntityNameMap.get( entityName ) );
      annotatedClassesByEntityNameMap.remove( entityName );
    }
  }
}

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

private void processHbmXml(XmlDocument metadataXml, Set<String> entityNames) {
  try {
    HbmBinder.bindRoot( metadataXml, createMappings(), CollectionHelper.EMPTY_MAP, entityNames );
  }
  catch ( MappingException me ) {
    throw new InvalidMappingException(
        metadataXml.getOrigin().getType(),
        metadataXml.getOrigin().getName(),
        me
    );
  }
  for ( String entityName : entityNames ) {
    if ( annotatedClassesByEntityNameMap.containsKey( entityName ) ) {
      annotatedClasses.remove( annotatedClassesByEntityNameMap.get( entityName ) );
      annotatedClassesByEntityNameMap.remove( entityName );
    }
  }
}

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

/**
 * Read package-level metadata.
 *
 * @param packageName java package name
 *
 * @return this (for method chaining)
 *
 * @throws MappingException in case there is an error in the mapping data
 */
public Configuration addPackage(String packageName) throws MappingException {
  LOG.debugf( "Mapping Package %s", packageName );
  try {
    AnnotationBinder.bindPackage( packageName, createMappings() );
    return this;
  }
  catch ( MappingException me ) {
    LOG.unableToParseMetadata( packageName );
    throw me;
  }
}

代码示例来源:origin: com.manydesigns/portofino-database

public Configuration buildSessionFactory(Database database) {
  try {
    Configuration configuration = new Configuration();
    setupConnection(configuration);
    setupConfigurationProperties(configuration);
    Mappings mappings = configuration.createMappings();
    //Class Mapping
    classMapping(database, mappings);
    //One2Many Mapping
    o2mMapping(database, configuration, mappings);
    //TODO
    //mappings.addSecondPass(new ToOneFkSecondPass(?));
    return configuration;
  }
  catch (Throwable ex) {
    // Make sure you log the exception, as it might be swallowed
    System.err.println("Initial SessionFactory creation failed." + ex);
    ex.printStackTrace();
    throw new ExceptionInInitializerError(ex);
  }
}

代码示例来源:origin: ManyDesigns/Portofino

public Configuration buildSessionFactory(Database database) {
  try {
    Configuration configuration = new Configuration();
    setupConnection(configuration);
    setupConfigurationProperties(configuration);
    Mappings mappings = configuration.createMappings();
    //Class Mapping
    classMapping(database, mappings);
    //One2Many Mapping
    o2mMapping(database, configuration, mappings);
    //TODO
    //mappings.addSecondPass(new ToOneFkSecondPass(?));
    return configuration;
  }
  catch (Throwable ex) {
    // Make sure you log the exception, as it might be swallowed
    System.err.println("Initial SessionFactory creation failed." + ex);
    ex.printStackTrace();
    throw new ExceptionInInitializerError(ex);
  }
}

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

final Mappings mappings = super.createMappings();
if (!GrailsHibernateUtil.usesDatasource(domainClass, dataSourceName)) {
  continue;

代码示例来源:origin: org.nakedobjects/nos-objectstore-hibernate

/**
 * Add all classes loaded in Naked Objects to the hibernate configuration
 */
public void configure(final Configuration cfg) {
  final Mappings mappings = cfg.createMappings();
  for (Iterator<PersistentNakedClass> iter = persistentClasses.getPersistentClasses(); iter.hasNext();) {
    final PersistentNakedClass persistentClass = iter.next();
    final String className = persistentClass.getName();
    if (mappings.getClass(className) == null) {
      LOG.debug("binding persistent class " + className);
      final Document doc4j = createDocument(persistentClass);
      org.w3c.dom.Document docW3c = createW3cDoc(doc4j);
      cfg.addDocument(docW3c);
      writeMappingDoc(doc4j, className);
    } else {
      LOG.info("class [" + className + "] is already mapped, skipping.. ");
    }
  }
}

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

final String logicalColumnName = normalizer.normalizeIdentifierQuoting( columnNames[index] );
try {
  final String columnName = createMappings().getPhysicalColumnName( logicalColumnName, table );
  columns[index] = new Column( columnName );
  unbound.add( columns[index] );

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

final String logicalColumnName = normalizer.normalizeIdentifierQuoting( columnNames[index] );
try {
  final String columnName = createMappings().getPhysicalColumnName( logicalColumnName, table );
  columns[index] = new Column( columnName );
  unbound.add( columns[index] );

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

/**
 * Read package-level metadata.
 *
 * @param packageName java package name
 *
 * @return this (for method chaining)
 *
 * @throws MappingException in case there is an error in the mapping data
 */
public Configuration addPackage(String packageName) throws MappingException {
  LOG.debugf( "Mapping Package %s", packageName );
  try {
    AnnotationBinder.bindPackage( packageName, createMappings() );
    return this;
  }
  catch ( MappingException me ) {
    LOG.unableToParseMetadata( packageName );
    throw me;
  }
}

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

applyDDLMethod.invoke(
    null,
    configuration.createMappings().getClasses().values(),
    configuration.getProperties(),
    dialect

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

applyDDLMethod.invoke(
    null,
    configuration.createMappings().getClasses().values(),
    configuration.getProperties(),
    dialect

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

/**
 * Overrides the default behaviour to including binding of Grails domain classes.
 */
@Override
protected void secondPassCompile() throws MappingException {
  if (configLocked) {
    return;
  }
  // set the class loader to load Groovy classes
  if (grailsApplication != null) {
    Thread.currentThread().setContextClassLoader(grailsApplication.getClassLoader());
  }
  configureDomainBinder(grailsApplication, domainClasses);
  for (GrailsDomainClass domainClass : domainClasses) {
    if (!GrailsHibernateUtil.usesDatasource(domainClass, dataSourceName)) {
      continue;
    }
    final Mappings mappings = super.createMappings();
    Mapping m = GrailsDomainBinder.getMapping(domainClass);
    mappings.setAutoImport(m == null || m.getAutoImport());
    GrailsDomainBinder.bindClass(domainClass, mappings, sessionFactoryBeanName);
  }
  super.secondPassCompile();
  configLocked = true;
}

代码示例来源:origin: apache/servicemix-bundles

Mappings mappings = config.createMappings();
for (TypeDefinitionBean typeDef : this.typeDefinitions) {
  mappings.addTypeDef(typeDef.getTypeName(), typeDef.getTypeClass(), typeDef.getParameters());

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

AnnotationBinder.bindDefaults( createMappings() );
isDefaultProcessed = true;

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

AnnotationBinder.bindDefaults( createMappings() );
isDefaultProcessed = true;

相关文章

Configuration类方法