You can take a try like this
Code:
Configuration cfg = new Configuration();
cfg.addResource("/hibernate.cfg.xml");
cfg.addClass(ca.ut.lms.hibernate.model.TCourse.class);
cfg.addClass(ca.ut.lms.hibernate.model.TUser.class);
sessionFactory = cfg.buildSessionFactory();
or modify you cfg.xml file Code:
Configuration conf = new Configuration().configure("/hibernate_rsys.cfg.xml");
sessionFactory = cfg.buildSessionFactory();
then you need not use cfg.addClass
modify your cfg.xml file like this
Code:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="dialect">net.sf.hibernate.dialect.MySQLDialect</property>
<property name="connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="connection.url">jdbc:mysql://localhost/oplms</property>
<property name="connection.username">root</property>
<property name="connection.password"></property>
<property name="connection.pool_size">1</property>
<property name="show_sql">false</property>
<!-- oplms mapping files. -->
<mapping resource="ca/ut/lms/hibernate/model/TCourse.hbm.xml" />
<mapping resource="ca/ut/lms/hibernate/model/TUser.hbm.xml" />
</session-factory>
</hibernate-configuration>