Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Annotationconfiguration deprecated and its replacement

Ads

 
 

Share on Google+Share on Google+

Java Coder
Annotationconfiguration deprecated and its replacement
1 Answer(s)      3 years and 7 months ago
Posted in : Hibernate

Hi,

In Hibernate 4 annotationconfiguration is deprecated. Can you tell me what will be its replacement?

Thanks

Ads
View Answers

December 19, 2013 at 11:51 AM


Hi,

You can use the following code in your program:

package net.roseindia;
import org.hibernate.SessionFactory;

import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtil {
    private static final SessionFactory sessionFactory;

    private static ServiceRegistry serviceRegistry;


    static {

        try {
/*
            Configuration configuration = new Configuration();
            sessionFactory = configuration.configure().buildSessionFactory();
    */

            Configuration configuration = new Configuration();
            configuration.configure();
            serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();        
            sessionFactory = configuration.buildSessionFactory(serviceRegistry);


        } catch (Throwable th) {

            System.err.println("Enitial SessionFactory creation failed" + th);

            throw new ExceptionInInitializerError(th);

        }

    }

    public static SessionFactory getSessionFactory() {

        return sessionFactory;

    }
}

Hope this will help you.

Read more tutorials at Hibernate Tutorials page.

Thanks


Ads









Related Tutorials/Questions & Answers:
Annotationconfiguration deprecated and its replacement
Annotationconfiguration deprecated and its replacement  Hi, In Hibernate 4 annotationconfiguration is deprecated. Can you tell me what will be its replacement? Thanks   Hi, You can use the following code in your
What is deprecated?
What is deprecated?  What is mean by deprecated element, method or class?   What is deprecated? Deprecated means condemned. A object... is showing a deprecated message that means it is either outdated or has been
Advertisements
MPMoviePlayerContentPreloadDidFinishNotification' is deprecated
MPMoviePlayerContentPreloadDidFinishNotification' is deprecated  Hi, While compiling compiler is giving following error: warning: 'MPMoviePlayerContentPreloadDidFinishNotification' is deprecated (declared at /Developer
UIKeyboardBoundsUserInfoKey is deprecated
UIKeyboardBoundsUserInfoKey is deprecated  On running my application i am getting a warning as given below... " UIKeyboardBoundsUserInfoKey is deprecated " What is the cause of it?? and what should i use instead
UILineBreakModeWordWrap is deprecated
UILineBreakModeWordWrap is deprecated  I am getting the error UILineBreakModeWordWrap is deprecated in IOS 6.0. What is the latest code to be used for this? Thanks   Hi, If you use the following code
Is buildSessionFactory() deprecated in hibernate 4?
Is buildSessionFactory() deprecated in hibernate 4?  Hi, I am trying to develop an application in Hibernate 4. I am using the Hibernate 4.3.0.final... sessions = cfg.buildSessionFactory(); But when I am using it in Hibernate 4 its
Java making a method deprecated
Java making a method deprecated  java making a method deprecated...; Declare "@Deprecated" before a method to create a method deprecated in your Java application. Though, it is not a correct way to use a deprecated class
HTTP_POST_VARS is deprecated
HTTP_POST_VARS is deprecated  HTTPPOSTVARS is deprecated. Which function to be used? Thanks   Hi, You should use: $id=$_GET["id"]; or $id=$_POST["id"]; thanks
Function split() is deprecated
Function split() is deprecated  Hi, The Function split() is deprecated in latest version of PHP 5.5.23? What is the solution? Thanks   Hi, Use the following function: array explode ( string $delimiter , string
Version of com.amadeus>session-replacement dependency
List of Version of com.amadeus>session-replacement dependency
Version of cocoon>cocoon-deprecated dependency
List of Version of cocoon>cocoon-deprecated dependency
The type ServiceRegistryBuilder is deprecated
is deprecated What is the correct way of creating the SessionFactory in Hibernate
Function mysql_db_query() is deprecated
Function mysql_db_query() is deprecated  Hi, In latest version of PHP Function mysqldbquery() is deprecated. What could be the solution? Thanks
Function mysql_db_query() is deprecated
Function mysql_db_query() is deprecated  Hi, In latest version of PHP Function mysqldbquery() is deprecated. What could be the solution? Thanks
dismissmodalviewcontrolleranimated first deprecated in ios 6.0
dismissmodalviewcontrolleranimated first deprecated in ios 6.0  ...: dismissmodalviewcontrolleranimated first deprecated in ios 6.0 I used the following...   This error is coming as this code is deprecated in the IOS 6. You
Maven Dependency session-replacement >> 0.2.0
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.2.0 in your project
Maven Dependency session-replacement >> 0.2.1
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.2.1 in your project
Maven Dependency session-replacement >> 0.3.0
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.3.0 in your project
Maven Dependency session-replacement >> 0.3.1
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.3.1 in your project
Maven Dependency session-replacement >> 0.4.0
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.4.0 in your project
Maven Dependency session-replacement >> 0.4.1
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.4.1 in your project
Maven Dependency session-replacement >> 0.2.2
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.2.2 in your project
Maven Dependency session-replacement >> 0.3.2
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.3.2 in your project
Maven Dependency session-replacement >> 0.4.2
You should include the dependency code given in this page to add Maven Dependency of com.amadeus >> session-replacement version0.4.2 in your project
Maven Dependency cocoon-deprecated >> 2.1.3
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.3 in your project
Maven Dependency cocoon-deprecated >> 2.1.4
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.4 in your project
Maven Dependency cocoon-deprecated >> 2.1.5.1
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.5.1 in your project
Maven Dependency cocoon-deprecated >> 2.1.6
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.6 in your project
Maven Dependency cocoon-deprecated >> 2.1.7
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.7 in your project
Maven Dependency cocoon-deprecated >> 2.1.8
You should include the dependency code given in this page to add Maven Dependency of cocoon >> cocoon-deprecated version2.1.8 in your project
struts2 filterdispatcher is deprecated please use the new filters
struts2 filterdispatcher is deprecated please use the new filters  Hi... on starup: struts2 filterdispatcher is deprecated please use the new filters... <<< is deprecated! Please use the new filters