Код: Выделить всё
Configuration configuration = new Configuration();
addAnnotatedClassesFromConfiguredPackages(configuration);
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder()
.configure() // configures settings from hibernate.cfg.xml
.build();
try {
LOGGER.info("Creating session factory");
sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
}
catch (Exception e) {
// The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
// so destroy it manually.
e.printStackTrace();
StandardServiceRegistryBuilder.destroy(registry);
}
Код: Выделить всё
org.hibernate.boot.MappingException: Association [com.domain.Instrument.internal] references an unmapped entity [com.domain.Instrument.internal] : origin(com/domain/Instrument.hbm.xml)
Как я могу добавить аннотированные классы в MetadataSources? Как я могу использовать объект конфигурации в
Код: Выделить всё
sessionFactory = new MetadataSources( registry ).buildMetadata().buildSessionFactory();
Подробнее здесь: https://stackoverflow.com/questions/791 ... ring-error