事情是这样的,我想把一个通用业务的model打成个jar(里面包含了hbm.xml和Pojo)因为以后都要用到,然后再通过hibernate的映射生成数据库;构想了之后,实施,貌似不行;现本人尚处于学习阶段,望各位不吝赐教
做法是..数据库生成类import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;public class ExportDB { public static void main(String[] args) {
Configuration c = new Configuration().configure();
SchemaExport e = new SchemaExport(c);
e.create(true, true);
}
}
hibernate.cfg.xml
<?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>
<!-- mysql-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/HibernateMappingTest</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<mapping resource="myModel.jar"/>
</session-factory>
</hibernate-configuration>
做法是..数据库生成类import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;public class ExportDB { public static void main(String[] args) {
Configuration c = new Configuration().configure();
SchemaExport e = new SchemaExport(c);
e.create(true, true);
}
}
hibernate.cfg.xml
<?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>
<!-- mysql-->
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1/HibernateMappingTest</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.use_sql_comments">true</property>
<mapping resource="myModel.jar"/>
</session-factory>
</hibernate-configuration>
解决方案 »
- 跪求帮忙HTTP Status 500 -
- 关于注册用户时的选择角色的问题
- 自己弄的登录的界面,如何进入邮件界面。大家救急啊!!
- 用Xfire开发的WEBSERVICE如何在weblogic8.1上成功运行
- 大家帮我看看这是什么问题啊 ?
- hibernate的问题, Cat is not mapped!!!!!!!!!!!
- Struts in action书那里可以DOWNLOAD
- java文件编译之后,不想重新启动weblogic,应该怎样配置weblogic???谢谢了,谁给的建议正确,分就给谁????
- java里有谁用过apache fop 来把xml等生成pdf文件,现在主要是连基本的中文字符显示都不行 ?????????????
- 谁能给出j2ee下载的完全正确的网址?100分就是他的了!
- 关于google地图
- 在使用hql 查询oracle中Timestamp类型的时间段时出现的错误
<mapping resource="classpath*:/com/test/mymodel/hbm/*.hbm.xml"/>