-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Migrate Hibernate 3 to Hibernate 4
PostPosted: Mon Apr 08, 2013 12:43 pm 
Newbie

Joined: Mon Feb 07, 2011 7:43 am
Posts: 6
Hi Guys

I need a problem to migrate from Hibernate 3 to Hibernate 4
I using the Configuration to get SessionFactory

Before I using the following code.

Code:
                Configuration conf = new Configuration();
      
      conf.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
      conf.setProperty("hibernate.connection.release_mode", "after_statement");
      conf.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
      conf.setProperty("hibernate.connection.datasource", "java:jboss/datasource/optimuslabsDS");
      
      conf.setProperty("hibernate.format_sql", hibernateFormatSql.toString());
      conf.setProperty("hibernate.show_sql", hibernateShowSql.toString());
//      conf.setProperty("hibernate.hbm2ddl.auto", "update");
      
      conf.setProperty("hibernate.default_schema", schemaName);
      
      //Hibernate 3.x
      conf.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JTATransactionFactory");
      conf.setProperty("hibernate.transaction.manager_lookup_class", "br.com.optimuslabs.infra.persistence.JBoss7TransactionManagerLookup");
      
      conf.setProperty("hibernate.transaction.flush_before_completion", "true");
      conf.setProperty("hibernate.current_session_context_class", "jta");
      conf.setProperty("jta.UserTransaction", "java:module/UserTransaction");
      
      for ( Class<?> c : this.jpaMappedClasses ){
         conf.addAnnotatedClass(c);
                }
      
      conf.addPackage("br.com.optimuslabs.entity"); //Le o package-info.java
      
           conf.buildSessionFactory();


Now I try the different forms.

Code:
                ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
      serviceRegistryBuilder
         .applySetting(AvailableSettings.DIALECT, "org.hibernate.dialect.PostgreSQL82Dialect")
         .applySetting(AvailableSettings.RELEASE_CONNECTIONS, "after_statement")
         .applySetting(AvailableSettings.DRIVER, "org.postgresql.Driver")
         .applySetting(AvailableSettings.DATASOURCE, "java:jboss/datasource/optimuslabsDS")
         .applySetting(AvailableSettings.TRANSACTION_STRATEGY, "org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory")
         .applySetting(AvailableSettings.JTA_PLATFORM, "org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform")
         .applySetting(AvailableSettings.FLUSH_BEFORE_COMPLETION, "true")
         .applySetting(AvailableSettings.CURRENT_SESSION_CONTEXT_CLASS, "jta");

                Configuration conf = new Configuration();
      conf.setProperty("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
      conf.setProperty("hibernate.connection.release_mode", "after_statement");
      conf.setProperty("hibernate.connection.driver_class", "org.postgresql.Driver");
      conf.setProperty("hibernate.connection.datasource", "java:jboss/datasource/optimuslabsDS");
      
      conf.setProperty("hibernate.format_sql", hibernateFormatSql.toString());
      conf.setProperty("hibernate.show_sql", hibernateShowSql.toString());
                conf.setProperty("hibernate.default_schema", schemaName);
                conf.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JTATransactionFactory");
      
      conf.setProperty("hibernate.transaction.flush_before_completion", "true");
      conf.setProperty("hibernate.current_session_context_class", "jta");
      conf.setProperty("jta.UserTransaction", "java:module/UserTransaction");

                conf.buildSessionFactory(serviceRegistryBuilder.buildServiceRegistry());


I can get the SessionFactory.
But When I save or insert this data the transaction is not commited and data is not persisted.
I'm not able to find the problem.

I need the help from community.

I too try using only ServiceRegistryBuilder and MetadataSources to get a ssesionFactory.
But in this case i get the Indexer class problem.

Code:
          MetadataSources metadataSources = new MetadataSources( serviceRegistryBuilder.buildServiceRegistry() );
          return metadataSources
         .getMetadataBuilder()
         .buildMetadata();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.