Hibernate reverse generates database errors

1. Ensure that the information in hibernate.cfg.xml is absolutely correct

 

2. Ensure that the code for reversely generating the database is correct

/**

* Spring uses Hibernate to reverse generate the database to create the database preparation:

* <P>

* 1. Configure the data source in applicationContext.xml

* </P>

* <P>

* 2. Configure the class to use Session to DaoBean <bean id="DSImpl" class="cn.xuan.util.DSImpl">

* <property name="sessionFactory"> <ref

* bean="sessionFactory"/></property></bean>

* </P>

* <P>

* 3. Use springIoc for new operation ApplicationContext ac = new

* ClassPathXmlApplicationContext( "applicationContext.xml"); DSImpl ds =

* (DSImpl) ac.getBean ("DSImpl");

* </P>

*/

public void ddl() {

System.out.println("DSImpl.ddl()");

Configuration cfg = new AnnotationConfiguration().configure();// Use annotation method

// Configuration cfg = new Configuration().configure(); //Use xml configuration file

SchemaExport export = new SchemaExport(cfg);

export.create(true, true);

}

 

-----------------------------------------------------------------------------------------------------------------------

 

because: because the value of the dialect drop-down list was accidentally modified in the view interface

 <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

 

so:org.hibernate.tool.hbm2ddl.SchemaExport:272 - Unsuccessful: create table

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327047018&siteId=291194637