util:properties không phải là thẻ hợp lệ để sử dụng trong hibernate.cfg.xml tập tin. Nếu bạn muốn đặt tất cả các chi tiết cấu hình DB trong một tệp thuộc tính thì bạn có thể đặt chúng trong hibernate.properties và xóa chúng khỏi hibernate.cfg.xml tập tin. Bằng cách này, các chi tiết DB sẽ được duy trì trong tệp thuộc tính.
Nếu bạn muốn duy trì một tệp riêng thay vì sử dụng tệp hibernate.properties thì bạn có thể thử cách này:
java.util.Properties properties = new Properties();
properties.load(new FileInputStream("db.properties"));
Configuration configuration = new Configuration();
configuration.configure("hibernate.cfg.xml").addProperties(properties);;
ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
.applySettings(configuration.getProperties()).build();
SessionFactory sessionFactory = configuration
.buildSessionFactory(serviceRegistry);