Discussion:
[Middlegen-user] Ejb3 - GeneratorType
Darren Hartford
2005-11-04 18:16:36 UTC
Permalink
Hey all,
I've been actively using the CMP30/ejb3 middlegen templates with great
success!

I however ran into this issue and rather start digging into the code
off-the-bat, first ask if anyone knows how to solve this problem.

I have a field in the database that is a String and the PRIMARY KEY.
This String will be populated by the application/user.

When using middlegen to generate the classes from the DB, I can not
figure out a way to stop it from doing this:

@javax.persistence.Id(generate = javax.persistence.GeneratorType.AUTO)

Any recommendations?

Thanks,
-D
Wouter Boers - List
2005-11-05 15:31:02 UTC
Permalink
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
Post by Darren Hartford
Hey all,
I've been actively using the CMP30/ejb3 middlegen templates with great
success!
I however ran into this issue and rather start digging into the code
off-the-bat, first ask if anyone knows how to solve this problem.
I have a field in the database that is a String and the PRIMARY KEY.
This String will be populated by the application/user.
When using middlegen to generate the classes from the DB, I can not
@javax.persistence.Id(generate = javax.persistence.GeneratorType.AUTO)
Any recommendations?
Thanks,
-D
-------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/middlegen-user
e***@tihlde.org
2005-11-07 08:03:47 UTC
Permalink
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
Post by Wouter Boers - List
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
Post by Darren Hartford
Hey all,
I've been actively using the CMP30/ejb3 middlegen templates with great
success!
I however ran into this issue and rather start digging into the code
off-the-bat, first ask if anyone knows how to solve this problem.
I have a field in the database that is a String and the PRIMARY KEY.
This String will be populated by the application/user.
When using middlegen to generate the classes from the DB, I can not
@javax.persistence.Id(generate = javax.persistence.GeneratorType.AUTO)
Any recommendations?
Thanks,
-D
-------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Darren Hartford
2005-11-07 11:20:48 UTC
Permalink
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
Post by e***@tihlde.org
Hey,
I'll be adding functionality to choose generator type for
each table.
Eivind Waaler
2005-11-07 18:03:47 UTC
Permalink
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.
Darren Hartford
2005-11-08 11:55:17 UTC
Permalink
Confirmed Eivind, that's working perfectly!
-----Original Message-----
Of Eivind Waaler
Sent: Monday, November 07, 2005 3:03 PM
Subject: RE: [Middlegen-user] Ejb3 - GeneratorType
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.
Loading...