Package org.hibernate.cfg

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


  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, "class, whatever" );
    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, "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

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

  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();
    Transaction tx = s.beginTransaction();
    Query q = s.createQuery( "from Boat" );
    assertEquals( 0, q.list().size() );
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

    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

 
  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

    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);
      }
View Full Code Here

  public void testGeneratedSql() {
    try {
      AnnotationConfiguration config = new AnnotationConfiguration();
      config.addAnnotatedClass(Address.class);
      config.addAnnotatedClass(Person.class);
      config.buildSessionFactory();
      String[] schema = config
          .generateSchemaCreationScript(new SQLServerDialect());
      for (String s : schema) {
        log.debug(s);
      }
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.