RE: Ejb3 - GeneratorType

Eivind Waaler <[email protected]> Mon, 7 Nov 2005 21:03:08 +0100 (CET)
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
Hi Darren,

I just commited a small fix to add a new preference to the plugin.

You should be able to set the generator type per table with the prefs 
file. From the generated sample prefs file:

...
cmp30.tables.flights.pk-generator-type=NONE
...
cmp30.tables.persons.pk-generator-type=AUTO

If you look at the vm template, you'll see it's not the most robust 
solution. I'll try to get a proper version up, with GUI settings 
and checking on the legal values.

But feel free to commit your own work. Would be cool if we could get out a 
proper version of the plugin with support for all major configuration 
options soon :)

.eivind

On Mon, 7 Nov 2005, Darren Hartford wrote:

> Hi Eivind, Wouter,
> I originally thought the same thing Wouter as far as the AUTO only being
> an Integer or a Long, however that is not always the case.  I do have
> one test application that uses the 'GUID' pattern where the
> auto-generated (although application-supplied in this scenario) key is
> actually a String.  GUID is something like the server name, the time,
> and the network address hashed together in a 32-bit char, can't remember
> exactly, but is a use-case for GENERATOR-type that is a String.
>
> Having said that, the GUID pattern is probably a new GENERATOR type not
> yet defined and does not match the definitions provided for these types
> (including the AUTO type):
>
> http://www.caucho.com/resin-3.0/ejb3/cmp-table.xtp
>
> * NONE - no auto generation for this field
> * IDENTITY - the database supplies the new key, e.g. auto_increment,
> SERIAL, or IDENTITY
> * SEQUENCE - use a SEQUENCE type to generate the key
> * TABLE - use a @TableGenerator for the key
> * AUTO - choose the generator based on the database
>   o MySQL - IDENTITY using auto_increment
>   o Resin - IDENTITY using auto_increment
>   o Postgres - SEQUENCE
>   o Oracle - SEQUENCE
>
> So, from a more educated standpoint, AUTO is designed to be underneath
> only IDENTITY/SEQUENCE, so yes, AUTO *should* only work if the field is
> an Integer/Long (unless SEQUENCE can also handle others).
>
> Regardless, is there something I can put in the preference file to set
> the per-table generator to NONE? If not, I'll start poking around to
> figure it out and commit it back.
>
> -D
>
>
>
>> Hey,
>>
>> I'll be adding functionality to choose generator type for
>> each table. From the spec, the available types are these 5:
>>
>> public enum GeneratorType { TABLE, SEQUENCE, IDENTITY, AUTO, NONE };
>>
>> Right now it's hardcoded with the AUTO option.
>>
>> Cannot String primary keys be auto-generated? Guess we could
>> make that a default option?
>>
>> Generator type will be available i the GUI and preferences.
>> I'll try to get a first version out during this week.
>>
>> .eivindw
>>
>>> Yes,
>>>
>>> Modify the velocity template to only generate this XDoclet tag when
>>> the primairy key is either a Long or Interger. That is the way its
>>> supposed to be anyways imho :)
>>>
>>> Regards, wouter
>>>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by:
> Tame your development challenges with Apache's Geronimo App Server. Download
> it for free - -and be entered to win a 42" plasma tv or your very own
> Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
> _______________________________________________
> middlegen-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/middlegen-user
>
>


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php