Package org.hibernate.cfg

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


    public AddResource(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


    Configuration cfg = new Configuration().setProperties( buildProperties() );


    String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
    for ( int i = 0; i < mappingFiles.length; i++ ) {
      cfg.addResource( mappingFiles[i] );
    }

    if ( customListeners != null && !customListeners.isEmpty() ) {
      Iterator entries = customListeners.entrySet().iterator();
      while ( entries.hasNext() ) {
View Full Code Here

    Configuration cfg = new Configuration().setProperties( buildProperties() );


    String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
    for ( int i = 0; i < mappingFiles.length; i++ ) {
      cfg.addResource( mappingFiles[i] );
    }

    if ( customListeners != null && !customListeners.isEmpty() ) {
      Iterator entries = customListeners.entrySet().iterator();
      while ( entries.hasNext() ) {
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

    Configuration cfg = new Configuration().setProperties( buildProperties() );


    String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
    for ( int i = 0; i < mappingFiles.length; i++ ) {
      cfg.addResource( mappingFiles[i] );
    }

    if ( customListeners != null && !customListeners.isEmpty() ) {
      Iterator entries = customListeners.entrySet().iterator();
      while ( entries.hasNext() ) {
View Full Code Here

    Configuration cfg = new Configuration().setProperties( buildProperties() );


    String[] mappingFiles = PropertiesHelper.toStringArray( mapResources, " ,\n\t\r\f" );
    for ( int i = 0; i < mappingFiles.length; i++ ) {
      cfg.addResource( mappingFiles[i] );
    }

    if ( customListeners != null && !customListeners.isEmpty() ) {
      Iterator entries = customListeners.entrySet().iterator();
      while ( entries.hasNext() ) {
View Full Code Here

  }

  public void testAllInOne() {
    Configuration cfg = new Configuration();

    cfg.addResource( getBaseForMappings() + "extendshbm/allinone.hbm.xml" );
    cfg.buildMappings();
    assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
    assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
    assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Employee" ) );
  }
View Full Code Here

  public void testOutOfOrder() {
    Configuration cfg = new Configuration();

    try {
      cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
      assertNull(
          "cannot be in the configuration yet!",
          cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
      );
      cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
View Full Code Here

      cfg.addResource( getBaseForMappings() + "extendshbm/Customer.hbm.xml" );
      assertNull(
          "cannot be in the configuration yet!",
          cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" )
      );
      cfg.addResource( getBaseForMappings() + "extendshbm/Person.hbm.xml" );
      cfg.addResource( getBaseForMappings() + "extendshbm/Employee.hbm.xml" );

      cfg.buildSessionFactory();

      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Customer" ) );
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.