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中加入映射字段。

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。