Package org.hibernate.cfg

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


    }
    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);
      }
    }
    public String toString() {
View Full Code Here


  String extraClassMapping = null;
 
  public static SessionFactory createSessionFactory(String extraClassMapping) {
    Configuration configuration = HibernateHelper.createConfiguration(null, null);
    Class clazz = ClassLoaderUtil.loadClass(extraClassMapping);
    configuration.addClass(clazz);
    return HibernateHelper.createSessionFactory(configuration, true);
  }
}
View Full Code Here

*/
public class SubclassProxyInterfaceTest extends TestCase {
  public void testSubclassProxyInterfaces() {
        final Configuration cfg = new Configuration()
        .setProperty( Environment.DIALECT, H2Dialect.class.getName() );
    cfg.addClass( Person.class );
    cfg.buildSessionFactory().close();
  }
}
View Full Code Here

      assertEquals( e.getType(), "file" );
      assertEquals( e.getPath(), "completelybogus.hbm.xml" );
    }

    try {
      cfg.addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
      fail();
    }
    catch ( MappingNotFoundException inv ) {
      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), "org/hibernate/Hibernate.hbm.xml" );
View Full Code Here

      assertTrue( inv.getPath().endsWith( ".hbm.xml" ) );
      assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
    }

    try {
      cfg.addClass( InvalidMapping.class );
      fail();
    }
    catch ( InvalidMappingException inv ) {
      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), "org/hibernate/test/mappingexception/InvalidMapping.hbm.xml" );
View Full Code Here

      java.sql.Connection conn = DriverManager.getConnection(
          "jdbc:mysql://stolas69.servequake.com/items", "sepi3", "1qazse4");
      // Hibernate configuration
      Configuration cfg = new Configuration();
      // cfg.addResource("Item.hbm.xml");
      cfg.addClass(Item.class).setProperty("hibernate.dialect",
          "org.hibernate.dialect.MySQLInnoDBDialect");
      cfg.setProperty("hibernate.hbm2ddl.auto", "update");
      cfg.setProperty("show_sql", "true");
      SessionFactory factory = cfg.buildSessionFactory();
      session = factory.openSession(conn);
View Full Code Here

    }
    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 JbpmException("couldn't add mapping for class "+className, e);
      }
    }
    public String toString() {
View Full Code Here

    public void apply(Object target, WireContext wireContext) {
      Configuration configuration = (Configuration) target;
      try {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        Class<?> persistentClass = Class.forName(className, true, classLoader);
        configuration.addClass(persistentClass);
      } catch (Exception e) {
        throw new JbpmException("couldn't add mapping for class "+className, e);
      }
    }
    public String toString() {
View Full Code Here

  static public Configuration createConfiguration() {
    final Configuration cfg = new Configuration();

    // Configure Hibernate mappings,this will look for the "hbm.xml" resources.
    // In alphabetical order:
    cfg.addClass(AuditEvent.class);

    return cfg;
  }

  public static void setConfiguration(Configuration cfg, Object lock) {
View Full Code Here

      assertEquals( e.getType(), "file" );
      assertEquals( e.getPath(), "completelybogus.hbm.xml" );
    }

    try {
      cfg.addClass( Hibernate.class ); // TODO: String.class result in npe, because no classloader exists for it
      fail();
    }
    catch ( MappingNotFoundException inv ) {
      assertEquals( inv.getType(), "resource" );
      assertEquals( inv.getPath(), "org/hibernate/Hibernate.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.