-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: PostgreSQL and Hibernate generator issues
PostPosted: Thu Dec 29, 2005 8:12 am 
Newbie

Joined: Sun Dec 19, 2004 8:10 pm
Posts: 10
Location: Australia
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0

Name and version of the database you are using:PostgreSQL 8.0

Hi,

I am using Hibernate with postgreSQL 8.0. I can read the data from my Database and also update existing records fine but when I try to insert the save fails on the generator. I have the database tables mapped as follows :

Code:
<class name="SessionToken" table="sessiontoken">
   <id name="sessiontokenid" column="sessiontokenid" type="java.lang.Integer" >
    <generator class="sequence" >
     </generator>
        </id>


However I have also tried native, increment and hilo, none of which seems to work.

I know there are people out there using Hibernate and postgreSQL so am hoping I am just missing something. The field is a serial field in the database.

Thanks
Connie
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 29, 2005 7:54 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Not sure what the error is as you did not supply it.
Having said the the obvious first thing is to check that you have created the sequence in the database. I would normally name a sequence when using the sequence (or native on a db using sequences) - to do that see docs. If it is not named it assumes you have a general sequence defined in the database - its name is 'hibernate_sequence'.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 30, 2005 7:32 am 
Newbie

Joined: Sun Dec 19, 2004 8:10 pm
Posts: 10
Location: Australia
Hi,


The error I am getting now is

Sessionworkplanner.hibernate.workplanner.dto.SessionToken@275
Hibernate: select nextval ('sessiontoken_sessiontokenid_seq')
Hibernate: insert into sessiontoken (userid, wamikey, session_id, logon_dt_tm, sessiontokenid) values (?, ?, ?, ?, ?)
net.sf.hibernate.JDBCException: Could not execute JDBC batch updateaccess workplanner.security.Access@29a046

If I have already created a record I can edit it to my hearts content. But any attempt to insert a record causes a failure and no data is saved.

I recreated the sequences and gave each table its own sequence, calling them individually in the mapping files but to no avail.

I use Informix at work and it works fine but I need to work on it at home and I only have postgreSQL at home. So I have rewritten all mappings and config file but I cannot insert a record.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.