'Alternative to using deprecated save method in hibernate
I am using the following code to save a person object into the database:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
public class Main {
public static void main(String[] args) {
Person person = new Person();
person.setID(1);
person.setName("name-1");
person.setAddress("address-1");
Configuration configuration = new Configuration().configure().addAnnotatedClass(Person.class);
SessionFactory sessionFactory = configuration.buildSessionFactory();
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
session.save(person);
transaction.commit();
}
}
I see that the save method is deprecated. What's the alternative approach that we are supposed to use?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
