Trouble with TIdGenerator


I am running in trouble with this entity:

  [Entity]
  [Table('DOMINIO')]
  [Sequence('SEQDOMINIO', 0, 1)]
  [Id('ID', TIdGenerator.IdentityOrSequence)]
  TEntityDominio = class(TNaharEntity)
  private
    FId: integer;
    FNome: string;

  private
    procedure SetNome(const Value: string);

  public
    [Column('ID', [TColumnProp.Unique, TColumnProp.Required, TColumnProp.NoUpdate])]
    property ID: integer read FId write FId;

    [Column('NOME', [], 20)]
    property Nome: string read FNome write SetNome;
  end;


The problem is: I clean my database to start over. Then the tables are created and standard records created for the first time.

I have a simple operation for this table, that is creating a new record, where the ID should be saved as 1.

But it always get saves as 2! it always start in 2, no matter what I change. I dont see on the code anything moving any value inadvertently.

How can I track this down in Aurelius?

Hard to tell, Aurelius just grabs the value from the sequence, can you verify using direct SQL if the sequence is returning 2 as initial value?

Another issue is that Aurelius doesn't support integer id with value equals to 0, so your sequence should NOT start with 0, but with 1.

In this version I posted I have set to 0, but even with 1 it always jump directly to 2.


It worked sometime before, but suddenly it is now always starting with 2. I am using ElevateDB last version. I have killed the database and started from nothing to make sure.

What you mean with direct SQL to retrieve the sequence, is the sequence stored on the database ?

Use the command listener to check what sql statements are being executed by aurelius. Try to execute the same statements in the empty (newly recreated) database to see what happens. It's hard to guess things without further tests, there is a need at least to determine if the problem is in Aurelius or in database itself.