事情是这样的,我想把一个通用业务的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>