David Hoag - 2002-08-26

JGrinder uses a PrimaryKeyStrategy implementation. There are a couple of different strategies available, one of which uses the Sequence.

The default strategy for the current release of JGrinder is a 'SelectAndUpdate' strategy. This strategy looks for a table called "Sequence" with a single column called "nextval". It selects the value from the table, increments the value by one, and updates the value in the table.

You can use this default strategy, or one of the others (including one that actually uses a real sequence), or write your own.

In your example you simply need to create a table called sequence containing a column called nextval.

There are two other stategies you can use:
GlobalSequence - Uses a real sequence called global_uid_seq
TableSequence - Uses a different sequence for each table called: <table-name>_uid_seq.

anRdbBrokerInstance.getBrokerPropertySource().setPrimaryKeyStrategy( <your-strat> );

----- Original Message -----
From: "Tareq
Subject: Postresql

> I was about to write an extension to support postgresql when I saw a
> response in the jgrinder forum from you that said that you had success
> with postgressql and the default RDBBroker. I am not having any luck since
> the sequence related funtions are not SQL92 compliant. eg.
>
> Create a sequence:
>
> CREATE SEQUENCE mysequence START 101;
>
> Select the next sequence: ( sequnece is automatically updated ).
>
> SELECT NEXTVAL( 'mysequence' );
>
> Here is the log:
>
> Connected to jdbc:postgresql:chartex
> 600 [main] INFO com.objectwave.persist.broker.DefaultConnectionSource  -
> Driver    PostgreSQL Native Driver
> 601 [main] INFO com.objectwave.persist.broker.DefaultConnectionSource  -
> Version   7.0
> 601 [main] INFO com.objectwave.persist.broker.DefaultConnectionSource  -
> Supports Transactions true
> 603 [main] INFO com.objectwave.persist.broker.DefaultConnectionSource  -
> Max Statements 1
> 603 [main] INFO com.objectwave.persist.broker.DefaultConnectionSource  -
> 618 [main] DEBUG com.objectwave.persist.broker.RDBBroker  - Asked to
> saveObjects. Count: 6Thread[main,5,main]
> 621 [main] DEBUG com.objectwave.persist.broker.RDBBroker  - Inserting to
> RDB @ URL "jdbc:postgresql:chartex"
> 629 [main] DEBUG com.objectwave.persist.broker.RDBConnection  - IDThread:
> Thread[main,5,main] : SELECT NEXTVAL FROM SEQUENCE A
> 640 [main] WARN com.objectwave.persist.broker.RDBConnection  - Exception
> SQL :'SELECT NEXTVAL FROM SEQUENCE A' Thread: Thread[main,5,main]
> java.sql.SQLException: ERROR:  Relation "sequence" does not exist
>
> Do you have any custom extensions to support postgressql ? If not I am
> getting ready to do so.
>
> Thanks
>
> Tareq