Я хочу настроить JPA в классе Java (не используя обычный подход persistence.xml
)
Вот пример того, что я делаю:
public SessionFactory getSessionFactory(){
Configuration configuration=new Configuration();
Properties settings= new Properties();
settings.put(Environment.DRIVER, "");
settings.put(Environment.URL, "");
settings.put(Environment.USER, "");
settings.put(Environment.PASS, "");
settings.put(Environment.DIALECT, "");
settings.put(Environment.SHOW_SQL, "true");
settings.put(Environment.DEFAULT_SCHEMA, "");
configuration.setProperties(settings);
configuration.addAnnotatedClass(Passenger.class);
ServiceRegistry serviceRegistry=new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
sessionFactory=configuration.buildSessionFactory(serviceRegistry);
}