1)当我将我的应用程序发送给我的老师时,我如何告诉它创建一些空表并在首次启动应用程序时使用示例数据填充它?我知道我可以在我的文件或其他东西中包含 sql 脚本。我可以指示hibrenate创建空表吗?我有我在我的应用程序中使用的实体。
2)当我的ide(NetNeans)启动时,我去服务并手动启动我的数据库(JavaDB),因为如果我不这样做,在应用程序启动时休眠抱怨他无法连接。我如何告诉休眠开始启动数据库(它在 localhost:1527 上)?
我的 hebernate.cfg:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hibernate.connection.driver_class">org.apache.derby.jdbc.ClientDriver</property>
<property name="hibernate.connection.url">jdbc:derby://localhost:1527/sample</property>
<property name="hibernate.connection.username">app</property>
<property name="hibernate.connection.password">app</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
<mapping resource="entity/PurchaseOrder.hbm.xml"/>
<mapping resource="entity/Customer.hbm.xml"/>
<mapping resource="entity/ProductCode.hbm.xml"/>
<mapping resource="entity/Product.hbm.xml"/>
<mapping resource="entity/MicroMarket.hbm.xml"/>
<mapping resource="entity/Manufacturer.hbm.xml"/>
<mapping resource="entity/DiscountCode.hbm.xml"/>
</session-factory>
</hibernate-configuration>
我没有很好的英语知识,而且很难在谷歌中形成查询。告诉我这些函数是如何调用的(如果它们存在的话)。
任何帮助,将不胜感激。提前致谢。