Package org.hibernate.cfg

Examples of org.hibernate.cfg.AnnotationConfiguration.configure()


            cfg.setNamingStrategy(
                    (NamingStrategy) ReflectHelper.classForName(namingStrategy).newInstance()
                );
        }
        if (configurationFile!=null) {
            cfg.configure( configurationFile );
        }

        String[] files = getFiles();
        for (int i = 0; i < files.length; i++) {
            String filename = files[i];
View Full Code Here


        AnnotationConfiguration configuration = new AnnotationConfiguration();

        // Perform normal configuration.

        configuration.configure();

        for (String packageName : packageNames)
        {
            configuration.addPackage(packageName);
View Full Code Here

     * @param outputFile Optional file to write out the SQL to.
     */
    public void hbm2ddl(boolean export, boolean create, boolean drop, String outputFile) {
        final AnnotationConfiguration configuration = new AnnotationConfiguration();
        try {
            configuration.configure(this.configuration.getURL());
        }
        catch (IOException e) {
            throw new IllegalArgumentException("Could not load configuration file '" + this.configuration + "'", e);
        }
       
View Full Code Here

* @author Emmanuel Bernard
*/
public class ConfigurationTest extends junit.framework.TestCase {
  public void testDeclarativeMix() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
    Transaction tx = s.beginTransaction();
View Full Code Here

    sf.close();
  }

  public void testIgnoringHbm() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
View Full Code Here

    sf.close();
  }

  public void testPrecedenceHbm() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    cfg.addAnnotatedClass( Boat.class );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
View Full Code Here

    sf.close();
  }

  public void testPrecedenceAnnotation() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class, hbm" );
    cfg.addAnnotatedClass( Boat.class );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
View Full Code Here

    sf.close();
  }

  public void testHbmWithSubclassExtends() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.addClass( Ferry.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
View Full Code Here

    sf.close();
  }

  public void testAnnReferencesHbm() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
    cfg.addAnnotatedClass( Port.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    SessionFactory sf = cfg.buildSessionFactory();
    assertNotNull( sf );
    Session s = sf.openSession();
View Full Code Here

        AnnotationConfiguration configuration = new AnnotationConfiguration();

        // Perform normal configuration.

        configuration.configure();

        for (String packageName : packageNames)
        {
            configuration.addPackage(packageName);
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.