Hibernate!!自己写程序过程中,忘记或者遇到的问题

关于用getCurrentSession(),忘记在hibernate.cfg.xml  中配置

在集成Hibernate的环境下(例如Jboss),要在hibernate.cfg.xml中session-factory段加入:

 1 <property name="current_session_context_class">jta</property>  

在不集成Hibernate的环境下(例如使用JDBC的独立应用程序),在hibernate.cfg.xml中session-factory段加入:

 1 <property name="current_session_context_class">thread</property>  

org.hibernate.MappingException: Unknown entity: com.hb.model.Group  

对于annotation方式,找不到实体类,一般是忘记加@Entity,或者是忘记在hibernate.cfg.xml中加入映射字段。

原文地址:https://www.cnblogs.com/Mokaffe/p/4176684.html