Package org.hibernate.cfg

Examples of org.hibernate.cfg.Configuration$MappingsImpl$TableDescription


 
  String configurationName;
  Descriptor configurationDescriptor;
 
  public Object construct(WireContext wireContext) {
    Configuration configuration = null;

    if (configurationName!=null) {
      configuration = (Configuration) wireContext.get(configurationName);

    } else if (configurationDescriptor!=null) {
      configuration = (Configuration) wireContext.create(configurationDescriptor, false);
     
    } else {
      configuration = wireContext.get(Configuration.class);
    }
   
    if (configuration==null) {
      throw new WireException("couldn't find configuration");
    }
   
    SessionFactory sessionFactory = configuration.buildSessionFactory();
   
    wireContext.addListener(new SessionFactoryCloser(sessionFactory));

    return sessionFactory;
  }
View Full Code Here


  List<Operation> cacheOperations;
  PropertiesDescriptor propertiesDescriptor;

  public Object construct(WireContext wireContext) {
    // instantiation of the configuration
    Configuration configuration = null;
    if (className!=null) {
      ClassLoader classLoader = wireContext.getClassLoader();
      Class<?> configurationClass = ReflectUtil.loadClass(classLoader, className);
      configuration = (Configuration) ReflectUtil.newInstance(configurationClass);
    } else {
      configuration = new Configuration();
    }
   
    // the naming strategy
    if (tablePrefix!=null) {
      configuration.setNamingStrategy(new PvmNamingStrategy(tablePrefix));

    } else if (namingStrategyClassName!=null) {
      ClassLoader classLoader = wireContext.getClassLoader();
      Class<?> namingStrategyClass = ReflectUtil.loadClass(classLoader, namingStrategyClassName);
      NamingStrategy namingStrategy = (NamingStrategy) ReflectUtil.newInstance(namingStrategyClass);
      configuration.setNamingStrategy(namingStrategy);
    }
   
    Properties properties = (Properties) propertiesDescriptor.construct(wireContext);
    configuration.addProperties(properties);
   
    return configuration;
  }
View Full Code Here

   
    return configuration;
  }
 
  public void initialize(Object object, WireContext wireContext) {
    Configuration configuration = (Configuration) object;
    apply(mappingOperations, configuration, wireContext);
    apply(cacheOperations, configuration, wireContext);
  }
View Full Code Here

    String fileName;
    public AddFile(String fileName) {
      this.fileName = fileName;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      configuration.addFile(fileName);
    }
View Full Code Here

    String className;
    public AddClass(String className) {
      this.className = className;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      try {
        Class<?> persistentClass = wireContext.getClassLoader().loadClass(className);
        configuration.addClass(persistentClass);
      } catch (Exception e) {
        throw new PvmException("couldn't add mapping for class "+className, e);
      }
    }
View Full Code Here

    String url;
    public AddUrl(String url) {
      this.url = url;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      try {
        configuration.addURL(new URL(url));
      } catch (Exception e) {
        throw new PvmException("couldn't add hibernate mapping from URL "+url, e);
      }
    }
View Full Code Here

    public SetCacheConcurrencyStrategy(String className, String concurrencyStrategy) {
      this.className = className;
      this.concurrencyStrategy = concurrencyStrategy;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      configuration.setCacheConcurrencyStrategy(className, concurrencyStrategy);
    }
View Full Code Here

    public SetCollectionCacheConcurrencyStrategy(String collection, String concurrencyStrategy) {
      this.collection = collection;
      this.concurrencyStrategy = concurrencyStrategy;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      configuration.setCollectionCacheConcurrencyStrategy(collection, concurrencyStrategy);
    }
View Full Code Here

    String resource;
    public AddResource(String resource) {
      this.resource = resource;
    }
    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      configuration.addResource(resource, wireContext.getClassLoader());
    }
View Full Code Here

    return (BasicServiceRegistryImpl) new ServiceRegistryBuilder().applySettings( properties ).buildServiceRegistry();
  }

  public static void main(String[] args) {
    try {
      Configuration cfg = new Configuration();

      boolean script = true;
      boolean drop = false;
      boolean create = false;
      boolean halt = false;
      boolean export = true;
      String outFile = null;
      String importFile = DEFAULT_IMPORT_FILE;
      String propFile = null;
      boolean format = false;
      String delim = null;

      for ( int i = 0; i < args.length; i++ ) {
        if ( args[i].startsWith( "--" ) ) {
          if ( args[i].equals( "--quiet" ) ) {
            script = false;
          }
          else if ( args[i].equals( "--drop" ) ) {
            drop = true;
          }
          else if ( args[i].equals( "--create" ) ) {
            create = true;
          }
          else if ( args[i].equals( "--haltonerror" ) ) {
            halt = true;
          }
          else if ( args[i].equals( "--text" ) ) {
            export = false;
          }
          else if ( args[i].startsWith( "--output=" ) ) {
            outFile = args[i].substring( 9 );
          }
          else if ( args[i].startsWith( "--import=" ) ) {
            importFile = args[i].substring( 9 );
          }
          else if ( args[i].startsWith( "--properties=" ) ) {
            propFile = args[i].substring( 13 );
          }
          else if ( args[i].equals( "--format" ) ) {
            format = true;
          }
          else if ( args[i].startsWith( "--delimiter=" ) ) {
            delim = args[i].substring( 12 );
          }
          else if ( args[i].startsWith( "--config=" ) ) {
            cfg.configure( args[i].substring( 9 ) );
          }
          else if ( args[i].startsWith( "--naming=" ) ) {
            cfg.setNamingStrategy(
                ( NamingStrategy ) ReflectHelper.classForName( args[i].substring( 9 ) )
                    .newInstance()
            );
          }
        }
        else {
          String filename = args[i];
          if ( filename.endsWith( ".jar" ) ) {
            cfg.addJar( new File( filename ) );
          }
          else {
            cfg.addFile( filename );
          }
        }

      }

      if ( propFile != null ) {
        Properties props = new Properties();
        props.putAll( cfg.getProperties() );
        props.load( new FileInputStream( propFile ) );
        cfg.setProperties( props );
      }

      if (importFile != null) {
        cfg.setProperty( Environment.HBM2DDL_IMPORT_FILES, importFile );
      }

      BasicServiceRegistryImpl serviceRegistry = createServiceRegistry( cfg.getProperties() );
      try {
        SchemaExport se = new SchemaExport( serviceRegistry, cfg )
            .setHaltOnError( halt )
            .setOutputFile( outFile )
            .setDelimiter( delim );
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.Configuration$MappingsImpl$TableDescription

Copyright © 2018 www.massapicom. 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.