Package org.hibernate.cfg

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


  public void testSimpleColumnAddition() {
    String resource1 = "org/hibernate/test/schemaupdate/1_Version.hbm.xml";
    String resource2 = "org/hibernate/test/schemaupdate/2_Version.hbm.xml";

    Configuration v1cfg = new Configuration();
    v1cfg.addResource( resource1 );
    new SchemaExport( v1cfg ).execute( false, true, true, false );

    SchemaUpdate v1schemaUpdate = new SchemaUpdate( v1cfg );
    v1schemaUpdate.execute( true, true );
View Full Code Here


    v1schemaUpdate.execute( true, true );

    assertEquals( 0, v1schemaUpdate.getExceptions().size() );

    Configuration v2cfg = new Configuration();
    v2cfg.addResource( resource2 );

    SchemaUpdate v2schemaUpdate = new SchemaUpdate( v2cfg );
    v2schemaUpdate.execute( true, true );
    assertEquals( 0, v2schemaUpdate.getExceptions().size() );
   
View Full Code Here

  };

  public void testConfiguraionSerializability() {
    Configuration cfg = new Configuration();
    for ( String file : FILES ) {
      cfg.addResource( "org/hibernate/test/" + file );
    }

    cfg.addAnnotatedClass( Serial.class );

    byte[] bytes = SerializationHelper.serialize( cfg );
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

      assertEquals( inv.getType(), "input stream" );
      assertEquals( inv.getPath(), null );
    }

    try {
      cfg.addResource( "nothere" );
      fail();
    }
    catch ( MappingNotFoundException inv ) {
      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), "nothere" );
View Full Code Here

      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), "nothere" );
    }

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

  }

  public void testDuplicateMapping() {
    String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";
    Configuration cfg = new Configuration();
    cfg.addResource( resourceName );
    cfg.buildMappings();
    try {
      cfg.addResource( resourceName );
      cfg.buildMappings();
      fail();
View Full Code Here

    String resourceName = "org/hibernate/test/mappingexception/User.hbm.xml";
    Configuration cfg = new Configuration();
    cfg.addResource( resourceName );
    cfg.buildMappings();
    try {
      cfg.addResource( resourceName );
      cfg.buildMappings();
      fail();
    }
    catch ( InvalidMappingException inv ) {
      assertEquals( inv.getType(), "resource" );
View Full Code Here

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

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

      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

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.