-->
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 Increment problem
PostPosted: Fri Jan 28, 2005 7:43 am 
Newbie

Joined: Fri Jan 28, 2005 6:26 am
Posts: 2
Hi there
I use increment for id generator for Postgresql 7.4 ...

Hibernate version is 2.1.6

My application is a desktop one. 4-5 clients are using the application
via network sharing. I mean they run same files from a sharing server.

After some insertions, i am getting the following duplicate key error..
Is there anyone who encountered this problem? can sharing method be the problem? Thanx in advance...

2005-01-15 11:40:42,279 [main] ERROR hibernate.util.JDBCExceptionReporter(46) -> ERROR: duplicate key violates unique constraint "turq_inventory_transactions_pkey"

2005-01-15 11:40:42,279 [main] ERROR hibernate.util.JDBCExceptionReporter(38) -> Could not execute JDBC batch update
Batch entry 0 insert into turq_inventory_transactions (transactions_amount_in, transactions_unit_price, transactions_total_price, transactions_discount, transactions_discount_amount, transactions_vat, transactions_vat_amount, transactions_vat_special_each, transactions_vat_special, transactions_vat_special_amount, transactions_cumilative_price, transactions_total_amount_out, created_by, creation_date, updated_by, last_modified, transactions_date, inventory_warehouses_id, inventory_units_id, engine_sequences_id, inventory_cards_id, inventory_transactions_id) values ( was aborted. Call getNextException() to see the cause.
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:108)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:118)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2311)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2261)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at com.turquaz.consignment.dal.ConDALAddConsignment.save(ConDALAddConsignment.java:40)
at

My Mapping file is the following..
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.turquaz.engine.dal.TurqInventoryTransaction"
table="turq_inventory_transactions"
>

<id
name="inventoryTransactionsId"
type="int"
column="inventory_transactions_id"
>
<generator class="increment" />
</id>

<property
name="transactionsAmountIn"
type="long"
column="transactions_amount_in"
not-null="true"
length="8"
/>
<property
name="transactionsUnitPrice"
type="java.math.BigDecimal"
column="transactions_unit_price"
not-null="true"
length="65535"
/>
<property
name="transactionsTotalPrice"
type="java.math.BigDecimal"
column="transactions_total_price"
not-null="true"
length="65535"
/>
<property
name="transactionsDiscount"
type="java.math.BigDecimal"
column="transactions_discount"
not-null="true"
length="65535"
/>
<property
name="transactionsDiscountAmount"
type="java.math.BigDecimal"
column="transactions_discount_amount"
not-null="true"
length="65535"
/>
<property
name="transactionsVat"
type="int"
column="transactions_vat"
not-null="true"
length="4"
/>
<property
name="transactionsVatAmount"
type="java.math.BigDecimal"
column="transactions_vat_amount"
not-null="true"
length="65535"
/>
<property
name="transactionsVatSpecialEach"
type="java.math.BigDecimal"
column="transactions_vat_special_each"
not-null="true"
length="65535"
/>
<property
name="transactionsVatSpecial"
type="java.math.BigDecimal"
column="transactions_vat_special"
not-null="true"
length="65535"
/>
<property
name="transactionsVatSpecialAmount"
type="java.math.BigDecimal"
column="transactions_vat_special_amount"
not-null="true"
length="65535"
/>
<property
name="transactionsCumilativePrice"
type="java.math.BigDecimal"
column="transactions_cumilative_price"
not-null="true"
length="65535"
/>
<property
name="transactionsTotalAmountOut"
type="long"
column="transactions_total_amount_out"
not-null="true"
length="8"
/>
<property
name="createdBy"
type="java.lang.String"
column="created_by"
not-null="true"
length="50"
/>
<property
name="creationDate"
type="java.sql.Date"
column="creation_date"
not-null="true"
length="4"
/>
<property
name="updatedBy"
type="java.lang.String"
column="updated_by"
not-null="true"
length="50"
/>
<property
name="lastModified"
type="java.sql.Date"
column="last_modified"
not-null="true"
length="4"
/>
<property
name="transactionsDate"
type="java.sql.Date"
column="transactions_date"
not-null="true"
length="4"
/>

<!-- Associations -->

<!-- bi-directional many-to-one association to TurqInventoryWarehous -->
<many-to-one
name="turqInventoryWarehous"
class="com.turquaz.engine.dal.TurqInventoryWarehous"
not-null="true"
>
<column name="inventory_warehouses_id" />
</many-to-one>
<!-- bi-directional many-to-one association to TurqInventoryUnit -->
<many-to-one
name="turqInventoryUnit"
class="com.turquaz.engine.dal.TurqInventoryUnit"
not-null="true"
>
<column name="inventory_units_id" />
</many-to-one>
<!-- bi-directional many-to-one association to TurqEngineSequence -->
<many-to-one
name="turqEngineSequence"
class="com.turquaz.engine.dal.TurqEngineSequence"
not-null="true"
>
<column name="engine_sequences_id" />
</many-to-one>
<!-- bi-directional many-to-one association to TurqInventoryCard -->
<many-to-one
name="turqInventoryCard"
class="com.turquaz.engine.dal.TurqInventoryCard"
not-null="true"
>
<column name="inventory_cards_id" />
</many-to-one>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 7:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Increment is absolutely not safe for such a situation, and this is also in the docs (thats just the same as a cluster). Use another generator.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 8:32 am 
Newbie

Joined: Fri Jan 28, 2005 6:26 am
Posts: 2
my application has to support both Postgresql and HSQLDB(1.7.2). I tried
native(it wil use sequence for Postgre, identity for HSQLDB, wont it?) before but could not run it with HSQLDB.. Then used the increment...


Actually I have found the reason now. I had forgot to make the primary keys identity in hsqldb script before..

Thanks again
Good Day

Onsel Armagan...


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.