geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piyush Agarwal (JIRA)" <>
Subject [jira] Commented: (DAYTRADER-14) Include sql script in the ear and use a gbean to create tables etc
Date Wed, 18 Oct 2006 18:27:35 GMT
    [ ] 
Piyush Agarwal commented on DAYTRADER-14:

I almost have the entire changes done which are required to make the above work. On testing
the drop tables and repopulate against Daytrader I came across a problem in repopulation part
which was causing DuplicateKeyException to be thrown. On analyzing I realized that the repopulate
db part which my code was calling after recreating the tables never deleted/repopulated the
KeyGen table. The KeySequenceDirect and KeySequenceBean cache blocks of Ids from this keygen
table and use them for holdings, orders etc. When the table is deleted, the caches dont realize
this and continue allocating ids from the cache until they run-out and go to the table to
get new block of ids. Since the table is re-created, the ids which were used before from the
cache are re-generated causing DuplicateKeyExceptions.

To solve this I thought of two options - 
1) Do not drop the keyGen table in my ddl script. The attempt to create the KeyGen table will
fail with SQLException in case it already exists. This will cause the repopulate code to work
as-is and prevent the DuplicateKeyException.
2) The cleaner way (avoiding all exceptions) will be to signal the KeySequenceDirect and KeySequenceBean
(depending on Direct or EJB mode) to drop their cached blocks when the repopulation of the
tables is being done. This will require some code to be added to the above classes but I think
its still do-able without a lot of new code. Also this will be the right way of doing it.

So currently I am going to evaluate the Option 2 unless anyone has something better in mind.

> Include sql script in the ear and use a gbean to create tables etc
> ------------------------------------------------------------------
>                 Key: DAYTRADER-14
>                 URL:
>             Project: DayTrader
>          Issue Type: Improvement
>          Components: EJB Tier
>    Affects Versions: 1.2
>            Reporter: David Jencks
>         Attachments: d-j-plan.xml, DAYTRADER-14.patch
> You can use the DatabaseIntitializationGBean (GERONIMO-2396) in a g. plan and include
the sql script in the ejb module so the database will get created if not already present.
This is way better than the previous hack of including a pre-built database in the car file.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


View raw message