-->
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: ID Generator Failing with PostgreSQL 8.1
PostPosted: Wed Oct 24, 2007 2:13 am 
Newbie

Joined: Sun Aug 05, 2007 9:21 pm
Posts: 5
Location: Durham, NC
Hey all, I got great help asking here last time, so I'm back. Here's my question.

I recently upgraded to PostgreSQL 8.1.9 from 7.4, and bumped up my JDBC driver accordingly. However, now on inserting into the database, I get this error.

Code:
2007-10-24 01:53:09,948 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: 23502
2007-10-24 01:53:09,948 ERROR [org.hibernate.util.JDBCExceptionReporter] - ERROR: null value in column "exid" violates not-null constraint
org.hibernate.exception.ConstraintViolationException: could not insert: [com.appleface.sbx.model.sbxdb.hibernate.Ex]
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:40)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2158)
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2638)
        at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:48)
        at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
        at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:298)
        at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:181)
        at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:107)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:187)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
        at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
        at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:507)
        at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:499)
        at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:495)
        at com.appleface.sbx.model.sbxdb.HibernateSessionFunctions.debugSave(HibernateSessionFunctions.java:27)
        at com.appleface.sbx.model.sbxdb.insertion.eri.ERISellerDomainResolver.resolveSender(ERISellerDomainResolver.java:195)
        at com.appleface.sbx.model.sbxdb.insertion.eri.EmailReceiptInsertion2.operate(EmailReceiptInsertion2.java:66)
        at com.appleface.sbx.model.sbxdb.active.ActiveSessionHandler.perform(ActiveSessionHandler.java:28)
        at com.appleface.sbx.model.sbxdb.insertion.ShoeboxEmailInserter.doInsertion(ShoeboxEmailInserter.java:44)
        at com.appleface.sbx.model.applogic.InsertionBean.insertEmailElement(InsertionBean.java:53)
        at com.appleface.sbx.model.applogic.emailsocket.XMLLauncher.run(XMLLauncher.java:128)
        at com.appleface.sbx.model.applogic.emailsocket.ReceiptServerSocketManager$Connection.run(ReceiptServerSocketManager.java:82)
        at com.appleface.sbx.model.applogic.emailsocket.ReceiptServerSocketManager.run(ReceiptServerSocketManager.java:102)
        at java.lang.Thread.run(Thread.java:595)
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "exid" violates not-null constraint
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1531)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1313)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:188)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:354)
        at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:308)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
        at org.hibernate.id.insert.AbstractSelectingDelegate.performInsert(AbstractSelectingDelegate.java:33)
        ... 24 more


I tried changing the "exid" generator to class="identity" from class="native" but it didn't fix the problem. I'm not doing anything fancy with JNI quite yet, so I'm curious why this started happening. (Also not sure if this is the sort of problem where setting show_sql=true actually helps) Thanks in advance!

-T

Hibernate version:
3.2.4.sp1

_________________
-------------------------
Anthony Bishopric


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 25, 2007 12:05 pm 
Newbie

Joined: Sun Aug 05, 2007 9:21 pm
Posts: 5
Location: Durham, NC
An update to this bug:
Turned on debugging to see that its inserting the ids appropriately for every table except for Exs, as seen in the stack trace below.

Code:
Hibernate: insert into EmailData (rawHeader, rawBody, recommendation, subject, date, viewed, htmlURI, textURI, headerURI, EDID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into AddressEmails (EMID, EDID) values (?, ?)
Hibernate: insert into EmailSender (EMID, EDID) values (?, ?)
Hibernate: insert into EmailSellerDomainRels (SDRID, EDID) values (?, ?)
Hibernate: insert into Exs (viewed, date) values (?, ?)
2007-10-25 11:30:35,462 WARN [org.hibernate.util.JDBCExceptionReporter] - SQL Error: 0, SQLState: 23502
2007-10-25 11:30:35,462 ERROR [org.hibernate.util.JDBCExceptionReporter] - ERROR: null value in column "exid" violates not-null constraint

etc...


Moved down to Postgres 7.4, moved JDBC driver down too
Triple checked that I was using Postgres Dialect
Moved up to Hibernate 3.2.5ga.

And still having issues :(. Is there any reason why Hibernate would not be inserting the exid in this situation? Here is the Ex mapping:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  <hibernate-mapping>
   <class name="com.appleface.sbx.model.sbxdb.hibernate.Ex" table="Exs" batch-size="5">
      <id name="id" column="EXID">
         <generator class="identity"/>
      </id>
      
      <property name="viewed" type="boolean"/>
      <property name="date" type="timestamp"/>
      
      <set name="emailData" table="ExEmailData" >
         <key column="EXID"></key>
         <many-to-many
         class="com.appleface.sbx.model.sbxdb.hibernate.EmailData"
         column="EDID"
         unique="true"/>
      </set>
      
      <set name="receipts" table="ExReceipts" >
         <key column="EXID"></key>
         <many-to-many
         class="com.appleface.sbx.model.sbxdb.hibernate.Receipt"
         column="RID"
         unique="true"/>
      </set>
      
      
      <set name="itemPhotoRelationships" table="ExItemPhotoRels" inverse="true">
         <key column="EXID"></key>
         <many-to-many
         class="com.appleface.sbx.model.sbxdb.hibernate.ItemPhotoRelationship"
         column="IPRID"
         unique="true"/>
      </set>

         
      <join table="ExSellerDomainRels" >
         <key column="EXID"/>
         <many-to-one name="sellerDomainRelationship"
         column="SDRID"
         not-null="true"
         class="com.appleface.sbx.model.sbxdb.hibernate.SellerDomainRelationship"/>
      </join>
      
      <join table="UserExs">
         <key column="EXID"/>
          <many-to-one name="user"
            column="UID"
            />
      </join>

       
   </class>
</hibernate-mapping>

_________________
-------------------------
Anthony Bishopric


Top
 Profile  
 
 Post subject: Fix
PostPosted: Sat Oct 27, 2007 1:17 pm 
Newbie

Joined: Sun Aug 05, 2007 9:21 pm
Posts: 5
Location: Durham, NC
In case anyone is interested, the fix was in changing the generator. Hibernate was writing the prepared statement without the id using either 'native' or 'identity', but worked for Hilo generator. Postgres does not support 'identity' and it reverted to 'native'

_________________
-------------------------
Anthony Bishopric


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.