pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vernon <vwu725@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: What Hibernate Object ID generator is recommanded for PG?
Date: Thu, 21 Apr 2005 14:13:49 -0700 (PDT)
Message-ID: <20050421211349.29702.qmail@web40529.mail.yahoo.com> (raw)

Hi,

Here is what I have:

Java class:

public class User {

	private Integer id;
...
}

Hibernate Mapping:

    <class name="com.ccc.domain.User" table="users">
        <id name="id" type="int" unsaved-value="null"
>
            <generator class="native"/>
        </id>
...
    </class>

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 



view thread (4+ messages)  latest in thread

Message-ID: <20050421211349.29702.qmail@web40529.mail.yahoo.com>
Permalink:  ../20050421211349.29702.qmail@web40529.mail.yahoo.com/
Also on:    postgresql.org/message-id/20050421211349.29702.qmail@web40529.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: vwu725@yahoo.com
  Subject: Re: What Hibernate Object ID generator is recommanded for PG?
  In-Reply-To: <20050421211349.29702.qmail@web40529.mail.yahoo.com>
  References: <20050421211349.29702.qmail@web40529.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox