From: Wojciech M. (JIRA) <no...@at...> - 2006-05-22 14:23:20
|
SchemaUpdate creates a sequence with error: java.sql.SQLException: ERROR: relation "rbrsequence" already exists --------------------------------------------------------------------------------------------------------------- Key: HHH-1772 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1772 Project: Hibernate3 Type: Bug Versions: 3.1.3 Environment: Spring 1.2.6, Hibernate 3.1.3, PostgreSQL driver 8.0-314, JBoss 4.0.3, Windows XP Reporter: Wojciech Matysik Attachments: ClaimDocument.hbm.xml, applicationContext-jdbc.xml I'v created HBM with id generator section: <id column="ID" access="property" name="id"> <generator class="native"> <param name="sequence">rbrSequence</param> <param name="schema">rbr</param> </generator> </id> SchemaUpdate is enabled. Following code inside org.springframework.orm.hibernate3.LocalSessionFactoryBean tries to invoke hibernate code: ----------------------------------------------------------------------------------------------- import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.NamingStrategy; import org.hibernate.dialect.Dialect; import org.hibernate.tool.hbm2ddl.DatabaseMetadata; import java.sql.Connection; import java.sql.SQLException; import java.sql.Statement; ... public void updateDatabaseSchema() throws HibernateException { ... Connection con = session.connection(); final Dialect dialect = Dialect.getDialect(configuration.getProperties()); DatabaseMetadata metadata = new DatabaseMetadata(con, dialect); String[] sql = configuration.generateSchemaUpdateScript(dialect, metadata); executeSchemaScript(con, sql); ... } ----------------------------------------------------------------------------------------------- where sql variable is: create sequence rbr.rbrSequence The method: executeSchemaScript throws exception: java.sql.SQLException: ERROR: relation "rbrsequence" already exists The problem is: rbrsequence has been created earlier, SchemaUpdate doesn't recognize it, and tries to create the same sequence again (I think that the schema parameter inside the generator params mislead SchemaUpdate). Other parts of Hibernate works properly. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |