Package org.hibernate.cfg

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


    annotationConfiguration.addAnnotatedClass(SozlesmelerDAO.class);
    annotationConfiguration.addAnnotatedClass(TeslimatSartlariDAO.class);
    annotationConfiguration.addAnnotatedClass(UlkeDAO.class);
    annotationConfiguration.addAnnotatedClass(UrunlerAnaDAO.class);
    annotationConfiguration.addAnnotatedClass(UrunlerExtraDAO.class);
    annotationConfiguration.configure("hibernate.cfg.xml");
  //  new SchemaExport(annotationConfiguration).create(true,true);
   
    Configuration configuration = new Configuration();
    configuration.configure();
    sessionFactory = configuration.buildSessionFactory();
View Full Code Here


public class Test2 {
  public static void main(String[] args) throws Exception {

    AnnotationConfiguration annotationConfiguration = new AnnotationConfiguration();
    annotationConfiguration.configure("/hibernate.cfg.xml");
    Class c = Student.class;
    Annotation[] annotations = c.getAnnotations();
    for (Annotation annotation : annotations) {
      System.out.println(annotation);
    }
View Full Code Here

   * Among other things this test case fails because the TrafficLightModel class contains a member of type java.util.Observer which cannot be persisted by hibernate properly.
   */
  @Test
  public void testHibernateAnnotationParser () {
    AnnotationConfiguration config = new AnnotationConfiguration();
    SessionFactory sessionFactory = config.configure("hibernate.cfg.xml")
    .buildSessionFactory();
    Session s = sessionFactory.getCurrentSession();
    Assert.assertNotNull(s);
  }

View Full Code Here

    config.setProperty("hibernate.connection.url", "jdbc:postgresql://"
        + DB_URL + ":" + DB_PORT + "/" + DB_NAME);
    config.setProperty("hibernate.connection.username", DB_USER);
    config.setProperty("hibernate.connection.password", DB_PW);
   
    SessionFactory sessionFactory = config.configure("hibernate.cfg.xml")
        .buildSessionFactory();
    Session s = sessionFactory.getCurrentSession();

    Transaction tx = null;
    try {
View Full Code Here

      configuration.setProperty("hibernate.current_session_context_class", "managed");
    }
   
    binder.bind(AnnotationConfiguration.class).toInstance(configuration);
   
    SessionFactory sessionFactory = configuration.configure().buildSessionFactory();   
    binder.bind(SessionFactory.class).toInstance(sessionFactory);

    // Guice/AssistedInject seems to need an explicit binding.
    // this may be able to go away in fiture version of guice
    binder.bind(HibernateUtil.class).to(HibernateUtilImpl.class);
View Full Code Here

         }
      }
      // hibernate.cfg.xml configuration
      if (cfgProperties==null && cfgResourceName==null)
      {
         configuration.configure();
      }
      else if (cfgProperties==null && cfgResourceName!=null)
      {
         configuration.configure(cfgResourceName);
      }
View Full Code Here

      {
         configuration.configure();
      }
      else if (cfgProperties==null && cfgResourceName!=null)
      {
         configuration.configure(cfgResourceName);
      }
      // Mapping metadata
      if (mappingClasses!=null)
      {
         for (String className: mappingClasses)
View Full Code Here

   * Getting a real Hibernate Session, from a memory database.
   */
  @Before
  public void setUp() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure().setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:mydvdsDB");
    session = cfg.buildSessionFactory().openSession();
    session.beginTransaction();
    dao = new DefaultDvdDao(session);
  }

View Full Code Here

   * Getting a real Hibernate Session, from a memory database.
   */
  @Before
  public void setUp() throws Exception {
    AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.configure().setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:mydvdsDB");
    session = cfg.buildSessionFactory().openSession();
    session.beginTransaction();
    dao = new DefaultUserDao(session);
  }

View Full Code Here

         }
      }
      // hibernate.cfg.xml configuration
      if (cfgProperties==null && cfgResourceName==null)
      {
         configuration.configure();
      }
      else if (cfgProperties==null && cfgResourceName!=null)
      {
         configuration.configure(cfgResourceName);
      }
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.