初学hibernate遇到的问题
1.hibernate Connection cannot be null when 'hibernate.dialect' not set
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Teacher t = new Teacher();
//student.setId(1);
t.setId(4);
t.setName("cc");
t.setTitle("高级");
Configuration cg = new Configuration();
cg.configure();//不要缺少或写在下面,这个是configure和serviceregistry之间
ServiceRegistry sr = new ServiceRegistryBuilder().applySettings(cg.getProperties()).buildServiceRegistry();
SessionFactory sf = cg.buildSessionFactory(sr);
Session s = sf.openSession();
s.beginTransaction();
s.save(t);
s.getTransaction().commit();
s.close();
sf.close();
}
}
http://www.cnblogs.com/slowly-keeping/archive/2012/04/18/2455293.html
2.org.hibernate.HibernateException: Dialect class not found: org.hibernate.dialect.MYSQL5Dialect
3. could not instantiate id generator
<generator class="native"> </generator>
或 indentity
因为我的的主键是自动增长的.
increment 生成策略 是hibernate 生成一个值 然后插到你的mysql数据库. 所以报错
http://bbs.csdn.net/topics/230057963

浙公网安备 33010602011771号