1.Hibernate 常见异常
net.sf.hibernate.MappingException
当出现net.sf.hibernate.MappingException: Error reading resource:…异常时一般是因为映射文
件出现错误。
当出现net.sf.hibernate.MappingException: Resource: … not found是因为XML配置文件没找到所致,有可能是放置目录不正确,或者没将其加入hibernate.cfg.xml中。
2. net.sf.hibernate.PropertyNotFoundException
当出现net.sf.hibernate.PropertyNotFoundException: Could not find a setter for property
name in class …时,原因一般是因为XML映射文件中的属性与对应的Java类中的属性的getter或setter方法不一致。
3. org.hibernate.id.IdentifierGenerationException
当出现org.hibernate.id.IdentifierGenerationException: ids for this class
must be manually assigned before calling
save():异常时,一般是因为
素
解决方案:
的取值可以为increment、identity、sequence、hilo、native……等,更多的可参考hibernate参考文档,一般取其值为native 。