Package org.hibernate.cfg

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


      assertEquals( inv.getPath(), resourceName );
      assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
    }

    try {
      cfg.addResource( resourceName, getClass().getClassLoader() );
      fail();
    }
    catch ( InvalidMappingException inv ) {
      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), resourceName );
View Full Code Here


    // Parent.hbm.xml contains the following entity include:
    //    <!ENTITY child SYSTEM "classpath://org/hibernate/test/util/dtd/child.xml">
    // which we are expecting the Hibernate custom entity resolver to be able to resolve
    // locally via classpath lookup.
    Configuration cfg = new Configuration();
    cfg.addResource( "org/hibernate/test/util/dtd/Parent.hbm.xml" );
    cfg.buildMappings();
  }
}
View Full Code Here

  public final void prepare() {
    Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    String[] resources = getResources();
    for ( int i = 0; i < resources.length; i++ ) {
      cfg.addResource( resources[i] );
    }
    factory = cfg.buildSessionFactory();
  }

  public final void complete() {
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 void testAllInOne() {
    Configuration cfg = new Configuration();

    cfg.addResource( getBaseForMappings() + "extendshbm/allinone.hbm.xml" );
    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

      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" ) );
      assertNotNull( cfg.getClassMapping( "org.hibernate.test.extendshbm.Person" ) );
View Full Code Here

  public void testNwaitingForSuper() {
    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/Employee.hbm.xml" );
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.