/resources/hibernate.properties
hibernate.connection.url = jdbc:mysql://localhost:3307/library
public static void main(String[] args) {
SessionFactory sessionFactory = new Configuration()
.addAnnotatedClass(org.example.entity.AuthorEntity.class)
.buildSessionFactory();
try (Session session = sessionFactory.openSession()) {
List<AuthorEntity> list = session.createQuery("from AuthorEntity", AuthorEntity.class).list();
AuthorEntity authorEntity = list.get(0);
System.out.println(authorEntity.getFirstName());
var transaction = session.beginTransaction();
authorEntity.setFirstName("Robert");
session.save(authorEntity);
transaction.commit();
}
}