У меня есть основной метод, использующий SchemaUpdate для отображения на консоли каких таблиц для изменения/создания, и он отлично работает в моем проекте Hibernate:
public static void main(String[] args) throws IOException {
//first we prepare the configuration
Properties hibProps = new Properties();
hibProps.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("jbbconfigs.properties"));
Configuration cfg = new AnnotationConfiguration();
cfg.configure("/hibernate.cfg.xml").addProperties(hibProps);
//We create the SchemaUpdate thanks to the configs
SchemaUpdate schemaUpdate = new SchemaUpdate(cfg);
//The update is executed in script mode only
schemaUpdate.execute(true, false);
...
Я хотел бы повторно использовать этот код в проекте JPA, не имея файла hibernate.cfg.xml(и никакого файла .properties), но файла persistence.xml(автоопределяемого в каталоге META-INF, как указано в JPA).
Я пробовал эту слишком простую адаптацию,
Configuration cfg = new AnnotationConfiguration();
cfg.configure();
но это исключение не удалось.
Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found
Кто-нибудь это сделал? Спасибо.