Hibernate:帮助解决异常org.hibernate.HibernateException:缺少表 [英] Hibernate : Help in resolving exception org.hibernate.HibernateException: Missing table
本文介绍了Hibernate:帮助解决异常org.hibernate.HibernateException:缺少表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将Hibernate用作我的项目的ORM.我使用mysql数据库
我在数据库目录"中有一个表产品".
我在应用程序中为实体产品放置了@Table(name ="Products",schema ="catalog")注释.
I am using Hibernate as ORM for my project. I use mysql Database
I have a table "Products" inside DB "catalog".
I have put the @Table(name="Products",schema="catalog") annotation for the entity Products in my application.
但是,当我尝试运行该应用程序时,出现以下异常.您能帮我解决这个问题吗?
However when I try to run the application I get the below exception. Can you please help me resolve this issue?
Exception:
Exception in thread "main" org.hibernate.HibernateException: Missing table:Products
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1281)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:508)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769)
at org.eros.purchase.db.utils.HibernateUtil.configure(HibernateUtil.java:17)
at Test.main(Test.java:14)
关于如何解决此问题的任何想法?
Any thoughts on how I can fix this?
推荐答案
请通过添加此属性来更新hibernate.cfg.xml文件
Please update your hibernate.cfg.xml file by adding this property
<property name="hibernate.hbm2ddl.auto">create</property>
or
<property name="hibernate.hbm2ddl.auto">update</property>
这篇关于Hibernate:帮助解决异常org.hibernate.HibernateException:缺少表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文