I want to set Hibernate configuration using Java code:
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.show_sql">true</property>
.........................
<property name="hibernate.hbm2ddl.auto">update</property>
<mapping class="com.web.models.RfidReaderModel"/>
<mapping class="com.web.models.SensorModel"/>
<mapping class="com.web.models.WhiteListModel"/>
<mapping class="com.web.models.BlackListModel"/>
<mapping class="com.web.models.ClientCardModel"/>
<mapping class="com.web.models.SystemUserModel"/>
<mapping class="com.web.models.AuditLogModel"/>
<mapping class="com.web.models.EntranceWFModel"/>
<mapping class="com.web.models.ExitWFModel"/>
<mapping class="com.web.models.RolesPermissions"/>
<mapping class="com.web.models.SystemUserRole"/>
</session-factory>
</hibernate-configuration>
I tried this code implementation:
public static SessionFactory buildTestSessionFactory() {
Configuration configuration = new Configuration();
//configuration.configure();
configuration.setProperty("hibernate.show_sql", "true");
configuration.setProperty("hibernate.connection.url", "jdbc:sqlite:/opt/testDB.sqlite");
configuration.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLiteDialect");
configuration.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
configuration.setProperty("hibernate.connection.release_mode", "auto");
configuration.setProperty("hibernate.connection.autoReconnect", "true");
configuration.setProperty("hibernate.hbm2ddl.auto", "update");
configuration.setProperty("hibernate.current_session_context_class", "thread");
return configuration.buildSessionFactory();
}
But I need to set also the mapping values:
<mapping class="com.web.models.EntranceWFModel"/>
How I can set them using Java code?