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

Hi,

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

Thanks

Advertisement
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










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
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
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
class with in its own objects?
class with in its own objects?  Is it a good idea to declare a class with in its own objects
datatypes in c++ and its sizes
datatypes in c++ and its sizes   What is mean by datatypes in C++ and what is the sizes of different datatypes
its urgent - Development process
its urgent  Hi how to write a program in core java , program is searching documents and contents in a existing folder or upload a folder or download a folder ,but important thing is how to search the contents
PLease reply its urgent
PLease reply its urgent   Write a java function that has the signature ΓΆβ?¬Ε?Public static int clock Inter sections(int hours, int minutes)ΓΆβ?¬Β? That takes a number of hours and minutes (up to several days), and returns
Storage medium that loses its contents
Storage medium that loses its contents  A Storage medium that loses its contents in the events of power failure is called? 1. Volatile storage 2. Non volatile storage 3. Permanent storage 4. All of the above 5. None
Conversion of unicode to its corresponding character
Conversion of unicode to its corresponding character  i have a string of unicodes e.g String s="\c0059\c0049\c3000" .. i need code for converting these unicodes to its corresponding alphabets.. pls if possible rep asap as i need
Modifying Text by Replacement
Modifying Text by Replacement     ...("Girish Tewari"):-Modify the text by Replacement Xml code...;@Program that Modify Text by Replacement  
its urgent for me - Development process
its urgent for me  Hi All, this is kalavathi,i am new to alfresco.present i am using alfresco3.9b version.my problem is i was writing code in java using alfresco.it is not working and i am not able to understand what
Edit Text by Insertion and Replacement
Edit Text by Insertion and Replacement   ... the Text in a DOM document. Methods which are used for insertion and replacement...;that Edit Text by Insertion and Replacement
write a program to demonstrate wrapper class and its methods......
write a program to demonstrate wrapper class and its methods......  write a program to demonstrate wrapper class and its methods
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
ABUT A FUNCTION AND ITS USE - Java Beginners
ABUT A FUNCTION AND ITS USE  SIR CAN U PLEASE TELL ME ABOUT parseInt(args[i]) a)its use? b)when it is used? C)is it related to string class
Logout if its not active for longer period in jsp
Logout if its not active for longer period in jsp  hi all, Please tell me how to log out the application if its not performing any activity... its not working please reply.. thanks in advance   Please visit
Difference in size of .java & its respective .class file
Difference in size of .java & its respective .class file  Hai, I had created & compiled a java class named sample.java. The size of sample.java is 340KB. Whereas the size of its respective class file sample.class is 137KB
its very urgent please help me
its very urgent please help me  how can i retrieve all images from ms access database and display in jsp pages
Ple help me its very urgent
Ple help me its very urgent  Hi.. I have one string 1)'2,3,4' i want do like this '2','3','4' ple help me very urgent