From: <leg...@at...> - 2004-11-05 19:08:02
|
The following comment has been added to this issue: Author: Dominik Drzewiecki Created: Fri, 5 Nov 2004 1:07 PM Body: I don't quite get why this issue has been closed. I think it is realy important that the default schema is picked up for sequences from hibernate.default_schema property. I am using xdoclet tags and do not want to explicitly specify schema name for sequence (but rather want it to be configured at runtime via hibernate.default_schema property, pretty the same as it is done for all tables): Therefore I do not have to specify schema in @hibernate.class /** * @hibernate.class * table = "SystemUser" * mutable = "true" */ but have to specify the full name for the sequence. /** * @hibernate.id * column = "id" * generator-class = "sequence" * unsaved-value = "null" * * @hibernate.generator-param * name = "sequence" * value = "SCHEMA_NAME.systemuser_id_seq" * * @return Returns the id. */ public Long getId() { return id; } This introduces hardcoded schema name. cheers, /dd --------------------------------------------------------------------- View this comment: http://opensource.atlassian.com/projects/hibernate/browse/HB-1219?page=comments#action_14761 --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/browse/HB-1219 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-1219 Summary: Hibernate doesn't respect hibernate.default_schema when using a sequence generator and PostgreSQL Type: Bug Status: Closed Priority: Major Resolution: DUPLICATE Original Estimate: Unknown Time Spent: Unknown Remaining: Unknown Project: Hibernate2 Components: core Versions: 2.1.6 Assignee: Reporter: Sandy McArthur Created: Fri, 10 Sep 2004 12:14 PM Updated: Fri, 5 Nov 2004 1:07 PM Environment: Hibernate 2.1.6, PostgreSQL 7.4.1, Java 1.4.2_03 (Mac OS X) Description: When you specify a default_scheme in the hibernate.cfg.xml the sequence generator doesn't respect the default_schema. Instead it uses the sequence in the "public" schema which is what PostgreSQL's schema search defaults to. Here is the generated SQL from when public.items_id_sequence exists: Hibernate: select nextval ('items_id_sequence') Hibernate: insert into beta2.items (name, id) values (?, ?) Note that the first line doens't specify a schema. Here is the generated SQL and following log lines when public.items_id_sequence doesn't exists: Hibernate: select nextval ('items_id_sequence') Sep 10, 2004 12:07:45 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 0, SQLState: 42P01 Sep 10, 2004 12:07:45 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: ERROR: relation "items_id_sequence" does not exist Sep 10, 2004 12:07:45 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 0, SQLState: 42P01 Sep 10, 2004 12:07:45 PM net.sf.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: ERROR: relation "items_id_sequence" does not exist Sep 10, 2004 12:07:45 PM net.sf.hibernate.JDBCException <init> SEVERE: Could not save object org.postgresql.util.PSQLException: ERROR: relation "items_id_sequence" does not exist at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139) at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154) at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101) at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43) at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50) at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231) at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:69) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1388) at test.Something.main(Something.java:24) Exception in thread "main" net.sf.hibernate.JDBCException: Could not save object at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:783) at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:738) at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1388) at test.Something.main(Something.java:24) Caused by: org.postgresql.util.PSQLException: ERROR: relation "items_id_sequence" does not exist at org.postgresql.util.PSQLException.parseServerError(PSQLException.java:139) at org.postgresql.core.QueryExecutor.executeV3(QueryExecutor.java:154) at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:101) at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:43) at org.postgresql.jdbc1.AbstractJdbc1Statement.execute(AbstractJdbc1Statement.java:515) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:50) at org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statement.java:231) at net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:69) at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:765) ... 3 more After some debugging I found that the params passed into net.sf.hibernate.id.SequenceGenerator.configure(...) do not contain a property under the "schema" key, which seems to be why SequenceGenerator.generate(..) doesn't know about the schema. --------------------------------------------------------------------- JIRA INFORMATION: 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 If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |