参考:http://stackoverflow.com/questions/6611437/how-to-make-hibernate-not-drop-tables

我遇到的问题就是:

List l = sess.createCriteria(News.class)
            .add( Restrictions.isNotEmpty("title"))
            .list();

抛出异常,Exception in thread "main" org.hibernate.MappingException: Property path [xxx.News.title] does not reference a collection

打开数据库查看表格,已经有的数据被清空了,select * from xxx_table 返回empty set,所以导致了这个异常

继续查看原因,是因为hibernate.cfg.xml中的<property name="hbm2ddl.auto">create</property>的问题,应该改成<property name="hbm2ddl.auto">update</property>

相关文章:

  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2021-10-12
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2021-07-10
  • 2022-12-23
  • 2021-05-21
  • 2022-03-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案