Package org.hibernate.cfg

Examples of org.hibernate.cfg.AnnotationConfiguration$ExtendedMappingsImpl


  }

  private SessionFactoryImplementor buildSessionFactory(List<Class<?>> classesUnderTest, List<String> configFiles) {
    assert classesUnderTest != null;
    assert configFiles != null;
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    for ( Class<?> clazz : classesUnderTest ) {
      cfg.addAnnotatedClass( clazz );
    }
    for ( String configFile : configFiles ) {
      InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
      cfg.addInputStream( is );
    }
    return ( SessionFactoryImplementor ) cfg.buildSessionFactory();
  }
View Full Code Here


  }

  public void testBlownPrecision() throws Exception {
   
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Bunny.class);
      config.addAnnotatedClass(PointyTooth.class);
      config.addAnnotatedClass(TwinkleToes.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
      String expectedSqlPointyTooth = "create table PointyTooth (id numeric(128,0) not null, " +
View Full Code Here

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

  public void testWithCustomNamingStrategy() throws Exception {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.setNamingStrategy(new DummyNamingStrategy());
      config.addAnnotatedClass(Address.class);
      config.addAnnotatedClass(Person.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
View Full Code Here

    }
  }

  public void testWithEJB3NamingStrategy() throws Exception {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.setNamingStrategy(EJB3NamingStrategy.INSTANCE);
      config.addAnnotatedClass(A.class);
      config.addAnnotatedClass(AddressEntry.class);
      config.buildSessionFactory();
      Mappings mappings = config.createMappings();
      boolean foundIt = false;

      for ( Iterator iter = mappings.iterateTables(); iter.hasNext()) {
        Table table = (Table) iter.next();
        log.info("testWithEJB3NamingStrategy table = " + table.getName());
View Full Code Here

    }
  }

  public void testWithoutCustomNamingStrategy() throws Exception {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Address.class);
      config.addAnnotatedClass(Person.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
View Full Code Here

/**
* @author Emmanuel Bernard
*/
public class OneToOneErrorTest extends junit.framework.TestCase {
  public void testWrongOneToOne() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Show.class )
        .addAnnotatedClass( ShowDescription.class );
    cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
    try {
      SessionFactory sf = cfg.buildSessionFactory();
      fail( "Wrong mappedBy does not fail property" );
    }
    catch (AnnotationException e) {
      //success
    }
View Full Code Here

 
 
  @BeforeClass
    @Parameters("auditStrategy")
    public void init(@Optional String auditStrategy) throws URISyntaxException {
        config = new AnnotationConfiguration();
        URL url = Thread.currentThread().getContextClassLoader().getResource(getHibernateConfigurationFileName());
        config.configure(new File(url.toURI()));

        if (auditStrategy != null && !"".equals(auditStrategy)) {
            config.setProperty("org.hibernate.envers.audit_strategy", auditStrategy);
View Full Code Here

   
  private Logger log = LoggerFactory.getLogger(BackquoteTest.class)
 
  public void testBackquotes() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Bug.class);
      config.addAnnotatedClass(Category.class);
      config.buildSessionFactory();
    }
    catch( Exception e ) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      log.debug(writer.toString());
View Full Code Here

   *  infinite loop in o.h.c.Configuration$MappingsImpl#getPhysicalColumnName().
   *  The same issue exists with getLogicalColumnName()
   */
  public void testInvalidReferenceToQuotedTableName() {
      try {
        AnnotationConfiguration config = new AnnotationConfiguration();
        config.addAnnotatedClass(Printer.class);
        config.addAnnotatedClass(PrinterCable.class);
        config.buildSessionFactory();
        fail("expected MappingException to be thrown");
      }
      //we WANT MappingException to be thrown
        catch( MappingException e ) {
          assertTrue("MappingException was thrown", true);
View Full Code Here

* @author Hardy Ferentschik
*/
public class AccessMappingTest extends TestCase {

  public void testInconsistentAnnotationPlacement() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Course1.class );
    cfg.addAnnotatedClass( Student.class );
    try {
      cfg.buildSessionFactory();
      fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
    }
    catch ( MappingException e ) {
      // success
    }
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.