0

I am using Hibernate for connecting to derby . i am using derby as an in-memory database for my application. I am completely new to hibernate and derby stuff. I have two xml files, sample.cfg.xml and sample.hbm.xml. The sample.hbm.xml contains the mapping between the table and the bean class. I am setting the in-memory db as follows:

       Dialect = org.hibernate.dialect.DerbyDialect
       DriverClassName = org.apache.derby.jdbc.EmbeddedDriver
       Url= jdbc:derby:unitTestDB;create=true
       UserName = ""
       Password=""

My question is , will the table be automatically created ? (by using the sample.hbm.xml as a reference) or do i need to create the table separately ? Pardon my ignorance as i am completely new to this.

4

1 回答 1

2

默认情况下,不会自动创建表。如果您建议 Hibernate 通过为配置中的属性提供所需的值来创建表hibernate.hbm2ddl.auto(属性位于您在查询中列出的其他属性的同一位置),则将创建表。

一般而言,最有可能开发create-drop是最佳选择,每次部署时,您都将从新数据库开始。对于内存来说,它当然总是新鲜的。其他选项是:validateupdatecreate

于 2012-07-18T14:34:00.603 回答