Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration.addResource()


      cfg.setProperty(Environment.USE_SECOND_LEVEL_CACHE, "true");
      cfg.setProperty(Environment.USE_QUERY_CACHE, "true");
      cfg.setProperty(Environment.CACHE_REGION_FACTORY, "org.hibernate.cache.infinispan.InfinispanRegionFactory");
      String[] mappings = new String[]{"org/hibernate/test/cache/infinispan/functional/Item.hbm.xml"};
      for (String mapping : mappings) {
         cfg.addResource(mapping, Thread.currentThread().getContextClassLoader());
      }
      cfg.buildMappings();
      Iterator iter = cfg.getClassMappings();
      while (iter.hasNext()) {
         PersistentClass clazz = (PersistentClass) iter.next();
View Full Code Here


                    throw new WGInvalidDatabaseException("Configured mapping file '" + db.getCreationOptions().get(DBOPTION_MAPPINGFILE) + "' does not exist or is no valid file.");
                }
                conf.addFile(mappingFile);
            }
            else if (db.getCreationOptions().containsKey(DBOPTION_MAPPINGRESOURCE)) {
                conf.addResource((String) db.getCreationOptions().get(DBOPTION_MAPPINGRESOURCE), this.getClass().getClassLoader());
            }
            else if (_ddlVersion == WGDatabase.CSVERSION_WGA5) {
               
                if (version.getPatchLevel() >= 3) {
                    conf.addResource(HIBERNATE_V5_P3_MAPPING_FILE, this.getClass().getClassLoader());
View Full Code Here

                conf.addResource((String) db.getCreationOptions().get(DBOPTION_MAPPINGRESOURCE), this.getClass().getClassLoader());
            }
            else if (_ddlVersion == WGDatabase.CSVERSION_WGA5) {
               
                if (version.getPatchLevel() >= 3) {
                    conf.addResource(HIBERNATE_V5_P3_MAPPING_FILE, this.getClass().getClassLoader());
                }
                else if (version.getPatchLevel() >= 2) {
                    conf.addResource(HIBERNATE_V5_P2_MAPPING_FILE, this.getClass().getClassLoader());
                }
                else {
View Full Code Here

               
                if (version.getPatchLevel() >= 3) {
                    conf.addResource(HIBERNATE_V5_P3_MAPPING_FILE, this.getClass().getClassLoader());
                }
                else if (version.getPatchLevel() >= 2) {
                    conf.addResource(HIBERNATE_V5_P2_MAPPING_FILE, this.getClass().getClassLoader());
                }
                else {
                    conf.addResource(HIBERNATE_V5_MAPPING_FILE, this.getClass().getClassLoader());
                }
            }
View Full Code Here

                }
                else if (version.getPatchLevel() >= 2) {
                    conf.addResource(HIBERNATE_V5_P2_MAPPING_FILE, this.getClass().getClassLoader());
                }
                else {
                    conf.addResource(HIBERNATE_V5_MAPPING_FILE, this.getClass().getClassLoader());
                }
            }
            else if (_ddlVersion == WGDatabase.CSVERSION_WGA4_1) {
                conf.addResource(HIBERNATE_V41_MAPPING_FILE, this.getClass().getClassLoader());
            } else {
View Full Code Here

                else {
                    conf.addResource(HIBERNATE_V5_MAPPING_FILE, this.getClass().getClassLoader());
                }
            }
            else if (_ddlVersion == WGDatabase.CSVERSION_WGA4_1) {
                conf.addResource(HIBERNATE_V41_MAPPING_FILE, this.getClass().getClassLoader());
            } else {
              conf.addResource(HIBERNATE_V3_MAPPING_FILE, this.getClass().getClassLoader());
            }
        }
        catch (MappingException e) {
View Full Code Here

                }
            }
            else if (_ddlVersion == WGDatabase.CSVERSION_WGA4_1) {
                conf.addResource(HIBERNATE_V41_MAPPING_FILE, this.getClass().getClassLoader());
            } else {
              conf.addResource(HIBERNATE_V3_MAPPING_FILE, this.getClass().getClassLoader());
            }
        }
        catch (MappingException e) {
            throw new WGInvalidDatabaseException("Exception parsing hibernate mapping", e);
        }
View Full Code Here

        cfg.addAnnotatedClass(
            serviceRegistry.getService( ClassLoaderService.class ).classForName( jaxbMapping.getClazz() )
        );
      }
      else if ( jaxbMapping.getResource() != null ) {
        cfg.addResource( jaxbMapping.getResource() );
      }
      else if ( jaxbMapping.getJar() != null ) {
        cfg.addJar( new File( jaxbMapping.getJar() ) );
      }
      else if ( jaxbMapping.getPackage() != null ) {
View Full Code Here

      Boolean useMetaInf = null;
      try {
        if ( resourceName.endsWith( META_INF_ORM_XML ) ) {
          useMetaInf = true;
        }
        cfg.addResource( resourceName );
      }
      catch( MappingNotFoundException e ) {
        if ( ! resourceName.endsWith( META_INF_ORM_XML ) ) {
          throw persistenceException( "Unable to find XML mapping file in classpath: " + resourceName );
        }
View Full Code Here

    public AddMappingResource(String resource) {
      this.resource = resource;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      configuration.addResource(resource, wireContext.getClassLoader());
    }
    public String toString() {
      return "adding mapping resource "+resource+" to hibernate configuration";
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.