Unknown entity: Students解决方法
【hibernate 5以上的版本不再需要 ServiceRegistry 来创建 sessionFactory
所以初始方法的代码可以改成
Configuration config = new Configuration().configure();
sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
transaction = session.beginTransaction();】
复制以上网友的评论表示感谢!
【hibernate 5以上的版本不再需要 ServiceRegistry 来创建 sessionFactory
所以初始方法的代码可以改成
Configuration config = new Configuration().configure();
sessionFactory = config.buildSessionFactory();
session = sessionFactory.openSession();
transaction = session.beginTransaction();】
复制以上网友的评论表示感谢!
2016-10-23
public static Session getSession() {
//加载配置文件
1 Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
//创建会话工厂
SessionFactory factory = configuration.buildSessionFactory();
//创建会话
Session session = factory.openSession();
return session;
}
//加载配置文件
1 Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
//创建会话工厂
SessionFactory factory = configuration.buildSessionFactory();
//创建会话
Session session = factory.openSession();
return session;
}
2016-10-21
</property>
<mapping resource="Students.hbm.xml"/>
<mapping resource="Students.hbm.xml"/>
2016-10-20
<property name="connection.password"></property>
<!-- 显示SQL语句 -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<!-- 定义方言 -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
<!-- 显示SQL语句 -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<!-- 定义方言 -->
<property name="dialect">
org.hibernate.dialect.MySQLDialect
2016-10-20
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/hibernate?useUnicode=true&amp;characterEncoding=utf8
</property>
<property name="connection.username">root</property>
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/hibernate?useUnicode=true&amp;characterEncoding=utf8
</property>
<property name="connection.username">root</property>
2016-10-20