X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2328053DA8 for ; Thu, 21 Apr 2005 20:40:20 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 16236-02 for ; Thu, 21 Apr 2005 23:40:11 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 090D9541BA for ; Thu, 21 Apr 2005 19:43:14 -0300 (ADT) Received: (qmail 13942 invoked from network); 21 Apr 2005 22:41:54 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 21 Apr 2005 22:41:54 -0000 Message-ID: <42682C7E.40201@fastcrypt.com> Date: Thu, 21 Apr 2005 18:43:10 -0400 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Vernon Cc: pgsql-jdbc@postgresql.org Subject: Re: What Hibernate Object ID generator is recommanded for References: <20050421211349.29702.qmail@web40529.mail.yahoo.com> In-Reply-To: <20050421211349.29702.qmail@web40529.mail.yahoo.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200504/126 X-Sequence-Number: 12733 Vernon, You need to create a sequence called hibernate_sequence create sequence hibernate_sequence; Dave Vernon wrote: >Hi, > >Here is what I have: > >Java class: > >public class User { > > private Integer id; >... >} > >Hibernate Mapping: > > > > > > >... > > >DB Table: > >create table USERS ( > id SERIAL UNIQUE primary key, >... >) > >When I call the save(object) method of Hibernate, I >get the following exception: > >2005-04-21 13:52:13,859 ERROR >org.springframework.web.servlet.DispatcherServlet - >Could not complete request >org.springframework.jdbc.BadSqlGrammarException: Bad >SQL grammar [] in task 'Hibernate operation'; nested >exception is java.sql.SQLException: ERROR: relation >"hibernate_sequence" does not exist >java.sql.SQLException: ERROR: relation >"hibernate_sequence" does not exist > at >org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1365) > at >org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1160) > at >org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:172) > at >org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:387) > at >org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:328) > at >org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:238) > at >org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92) > at >net.sf.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:64) > at >net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:774) > at >net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747) > at >org.springframework.orm.hibernate.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:386) > at >org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:243) > at >org.springframework.orm.hibernate.HibernateTemplate.save(HibernateTemplate.java:383) > >It seems the native ID generator doesn't work properly >in PG. After changing the generator to sequence. I get >the same exception. According to the Hibernate >documentation, that is the right way. Any suggestions >on the subject? > >Thanks, > >Vernon > >__________________________________________________ >Do You Yahoo!? >Tired of spam? Yahoo! Mail has the best spam protection around >http://mail.yahoo.com > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561