geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Neal Sanche <n...@nsdev.org>
Subject Key Generator Questions
Date Tue, 13 Jun 2006 03:58:56 GMT
Hi All,

Yesterday I had some fun with the sequence-table key generator. I had 
this fragment at the end of my Entity deployment plan.

      <pkgen:key-generator>
        <pkgen:sequence-table>
          <pkgen:table-name>sequence</pkgen:table-name>
          <pkgen:sequence-name>reminder</pkgen:sequence-name>
          <pkgen:batch-size>1</pkgen:batch-size>
        </pkgen:sequence-table>
      </pkgen:key-generator>

I know, I should increase my batch-size, but really I am only doing one 
at a time. But that's not my problem. Why doesn't the key-generator 
create the table if it doesn't already exist? It took me quite some time 
to figure out that it was looking for a table with two columns, one 
called 'name' and one called 'value'. Yeah, I know, it's pretty easy to 
guess it, but I couldn't find it documented. I'm sure I didn't look 
everywhere, and could have looked in the source code to find the columns.

Once I created my table, the application started throwing exceptions 
like crazy! It turned out the misleading 'Transaction already rolled 
back' errors were because the record in the table didn't exist. I'm sure 
it would be super easy to create the record if it wasn't already there, 
and start the numbering at 1. I'm just so surprised it doesn't already 
have this ability. I'm sure I'm missing something, right?

So, as far as I know, in order to get the key generator to work, I have 
to create the sequence table:

create table sequence (name varchar(240) not null primary key, value 
integer);

And then add the sequence key:

insert into sequence values ('reminder',1);

And then it'll go. Before that it just complains loudly and rolls back 
my transaction.

What am I missing?

Cheers.

-Neal



Mime
View raw message