hibernate.connection.url=jdbc:mysql://localhost:3306/mydatabase hibernate.connection.username=myusername hibernate.connection.password=mypassword @Entity @Table(name = "employees") public class Employee { @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private int id; @Column(name = "name", nullable = false) private String name; } SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); Session session = sessionFactory.openSession(); Transaction transaction = session.beginTransaction(); transaction.commit(); session.close(); sessionFactory.close();


上一篇:
下一篇:
切换中文