Package org.hibernate.cfg

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


  public void testDefaultPropertyAccessIsInherited() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Horse.class );
    cfg.addAnnotatedClass( Animal.class );

    SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory();
    EntityMetamodel metaModel = factory.getEntityPersister( Animal.class.getName() )
        .getEntityMetamodel();
    PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
    assertTrue(
        "Property access should be used since explicity configured via @Access",
View Full Code Here


   */
  public void testAccessOnClassAndId() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass( Course8.class );
    cfg.addAnnotatedClass( Student.class );
    cfg.buildSessionFactory();
  }
}
View Full Code Here

  public void testBuildingMetamodelWithParameterizedCollection() {
    AnnotationConfiguration cfg = new AnnotationConfiguration( );
    configure( cfg );
    cfg.addAnnotatedClass( WithGenericCollection.class );
    cfg.buildMappings();
    SessionFactoryImplementor sfi = (SessionFactoryImplementor) cfg.buildSessionFactory();
    MetamodelImpl.buildMetamodel( cfg.getClassMappings(), sfi );
  }

  public void testLogicalManyToOne() throws Exception {
    final EntityType<JoinedManyToOneOwner> entityType = factory.getMetamodel().entity( JoinedManyToOneOwner.class );
View Full Code Here

 
  public void testMiscplacedImmutableAnnotation() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Foobar.class);
      config.buildSessionFactory();
      fail();
    } catch (AnnotationException ae) {
      log.debug("succes");
    }
  }
View Full Code Here

    p.put( "hibernate.show_sql", "true" );
    ac.setProperties( p );
    ac.addAnnotatedClass( Plane.class );
    SessionFactory sf;
    try {
      sf = ac.buildSessionFactory();
      fail( "Driver property overriding should work" );
      sf.close();
    }
    catch (HibernateException he) {
      //success
View Full Code Here

    try {
      cfg.addAnnotatedClass( Flight.class );
      cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
      cfg.addResource( "org/hibernate/test/annotations/orm.xml" );
      cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml" );
      cfg.buildSessionFactory();
      fail( "Should not be able to map the same entity name twice" );
    }
    catch (AnnotationException ae) {
      //success
    }
View Full Code Here

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();
    Query q = s.createQuery( "from Boat" );
    assertEquals( 0, q.list().size() );
View Full Code Here

  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();
    Transaction tx = s.beginTransaction();
    Query q;
    try {
View Full Code Here

  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();
    s.getTransaction().begin();
    Boat boat = new Boat();
    boat.setSize( 12 );
View Full Code Here

    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 );
    Session s = sf.openSession();
    s.getTransaction().begin();
    Boat boat = new Boat();
    boat.setSize( 12 );
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.