Package org.hibernate.cfg

Examples of org.hibernate.cfg.AnnotationConfiguration$ExtendedMappingsImpl


  protected void buildConfiguration() throws Exception {
    if ( sessions != null ) {
      sessions.close();
    }
    try {
      setCfg( new AnnotationConfiguration() );
      // by default use the new id generator scheme...
      cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
      configure( cfg );
      if ( recreateSchema() ) {
        cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
View Full Code Here


  private Logger log = LoggerFactory.getLogger(FkCircularityTest.class);

  public void testJoinedSublcassesInPK() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(A.class);
      config.addAnnotatedClass(B.class);
      config.addAnnotatedClass(C.class);
      config.addAnnotatedClass(D.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
      log.debug("success");
View Full Code Here

    }
  }

  public void testDeepJoinedSuclassesHierachy() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(ClassA.class);
      config.addAnnotatedClass(ClassB.class);
      config.addAnnotatedClass(ClassC.class);
      config.addAnnotatedClass(ClassD.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new HSQLDialect());
      for (String s : schema) {
        log.debug(s);
      }
      log.debug("success");
View Full Code Here

public class FetchProfileTest extends TestCase {

  private Logger log = LoggerFactory.getLogger( FetchProfileTest.class );

  public void testFetchProfileConfigured() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( SupportTickets.class );
    config.addAnnotatedClass( Country.class );
    SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory();

    assertTrue(
        "fetch profile not parsed properly",
        sessionImpl.containsFetchProfileDefinition( "customer-with-orders" )
    );
View Full Code Here

        sessionImpl.containsFetchProfileDefinition( "package-profile-1" )
    );
  }

  public void testWrongAssociationName() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer2.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

      log.trace( "success" );
    }
  }

  public void testWrongClass() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer3.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

      log.trace( "success" );
    }
  }

  public void testUnsupportedFetchMode() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer4.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );

    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

      log.trace( "success" );
    }
  }

  public void testXmlOverride() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer5.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );
    InputStream is = Thread.currentThread()
        .getContextClassLoader()
        .getResourceAsStream( "org/hibernate/test/annotations/fetchprofile/mappings.hbm.xml" );
    config.addInputStream( is );
    SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory();

    assertTrue(
        "fetch profile not parsed properly",
        sessionImpl.containsFetchProfileDefinition( "orders-profile" )
    );

    // now the same with no xml
    config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer5.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( Country.class );
    try {
      config.buildSessionFactory();
      fail();
    }
    catch ( MappingException e ) {
      log.trace( "success" );
    }
View Full Code Here

      log.trace( "success" );
    }
  }

  public void testPackageConfiguredFetchProfile() {
    AnnotationConfiguration config = new AnnotationConfiguration();
    config.addAnnotatedClass( Customer.class );
    config.addAnnotatedClass( Order.class );
    config.addAnnotatedClass( SupportTickets.class );
    config.addAnnotatedClass( Country.class );
    config.addPackage( Customer.class.getPackage().getName() );
    SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory();

    assertTrue(
        "fetch profile not parsed properly",
        sessionImpl.containsFetchProfileDefinition( "package-profile-1" )
    );
View Full Code Here

  /**
   * Reads metadata from annotated classes and packages into the
   * AnnotationConfiguration instance.
   */
  protected final void postProcessMappings(Configuration config) throws HibernateException {
    AnnotationConfiguration annConfig = (AnnotationConfiguration) config;
    if (this.annotatedClasses != null) {
      for (int i = 0; i < this.annotatedClasses.length; i++) {
        annConfig.addAnnotatedClass(this.annotatedClasses[i]);
      }
    }
    if (this.annotatedPackages != null) {
      for (int i = 0; i < this.annotatedPackages.length; i++) {
        annConfig.addPackage(this.annotatedPackages[i]);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.hibernate.cfg.AnnotationConfiguration$ExtendedMappingsImpl

Copyright © 2018 www.massapicom. 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.