Hibernate Configuration with only hibernate.properties file. Without any hibernate.cfg.xml

Is it possible to use only hibernate.properties file to configure hibernate without any hibernate.cfg.xml file?

I have defined the required properties in hibernate.properties file.

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://localhost:3306/dev
hibernate.connection.username=root
hibernate.connection.password=
hibernate.connection.pool_size=1
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider
hibernate.hbm2ddl.auto=update

Hibernate shows :

Loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cache.provider_class=org.hibernate.cache.NoCacheProvider, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.format_sql=true, hibernate.connection.username=root, hibernate.hbm2ddl.auto=update, hibernate.connection.url=jdbc:mysql://localhost:3306/dev, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****, hibernate.connection.pool_size=1}

but it still asks for cfg.xml :

Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [hibernate.cfg.xml]

Answers


It is possible

SessionFactory factory = new Configuration().buildSessionFactory();

Need Your Help

how to exclude image while saving Rss Feed In dataBase and need to show full Feed Description in page

c# asp.net rss

while i am saving RssFeed in Database all Fields are saving like link,Id etc but coming to Description it saving only smalldescription until image Src coming and stopping there onwards.i just want...

Corona sdk allow device volume control

android sdk controls corona volume

I am using a runtime listener in a Corona sdk game, and it works, however what I am really interested in is having my game not interfere with the user setting the volume on their droid phone or tab...