openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Sutter <kwsut...@gmail.com>
Subject Re: Generators
Date Thu, 30 Jul 2009 16:13:19 GMT
On Wed, Jul 29, 2009 at 6:16 AM, MiƂosz Tylenda <mtylenda@o2.pl> wrote:

>
> My experience suggests me that GenerationType.TABLE is the default if you
> do not specify GenerationType or specify GenerationType.AUTO. This happens
> regardless of DBDictionary being used and regardless of any properties the
> DBDictionary sets. I guess the idea behind this is that a sequence table is
> the most portable of GenerationTypes across databases.


I agree that the TABLE generation is the most portable.  And, I also believe
that this is what we default to when AUTO is used.  The documentation
supports this.  But, I think our documentation is a little confusing in this
area as well.  This is probably due to the mapping of previous OpenJPA
features to the new JPA standards.

For example, the very end of section 6 Generators [1], there is the
following statement:

"In JPA, set your GeneratedValue annotation's strategy attribute to AUTO to
use the configured system sequence. Or, because AUTO is the default
strategy, use the annotation without attributes: "

The confusing aspect in my mind is that the "configured system sequence"
sounds like a database sequence, but in reality, it's referring to the
"OpenJPA system sequence", which could be a TABLE generator.  Kind of
confusing.

[1]
http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/manual.html#ref_guide_sequence

Kevin


>
>
> Regards,
> Milosz
>
> >
> > Kevin
> >
> > It is true that a field can override the default generation strategy to
> use sequences; for example I have the following sequence generator defined:
> > @SequenceGenerator(name="myseq",sequenceName="my_seq",initialValue=5)
> >
> > And a field using this generator:
> >     @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="myseq")
> >     public int getColumn() { ... }
> >
> > This works correctly.  However, given the field:
> >
> >     @Id
> >     @GeneratedValue
> >     public int getId() { ... }
> >
> > This will use the OPENJPA_SEQUENCE_TABLE unless
> > a) I specify (strategy=GenerationType.SEQUENCE), or
> > b) I set openjpa.Sequence=native
> >
> > My dictionary does not set sequenceSQL, sequenceSchemaSQL or
> sequenceNameSQL, since it wasn't clear what these should return, but I have
> set nextSequenceQuery and overridden getSequencesSQL(String, String)
> >
> > Is the lack of these attributes the cause for GenerationType.TABLE being
> the default?
> >
> > Alan
> >
> > -----Original Message-----
> > From: Kevin Sutter [mailto:kwsutter@gmail.com]
> > Sent: 27 July 2009 19:22
> > To: dev@openjpa.apache.org
> > Subject: Re: Generators
> >
> > Hi Alan,
> > I wonder if our documentation is in sync with the code...  The default
> value
> > for openjpa.Sequence is table.  But, I believe we override that if
> certain
> > attributes within the Dictionary are set.  For example, sequenceSQL,
> > sequenceSchemaSQL, and sequenceNameSQL are attributes that get set by
> data
> > dictionaries that support Sequences natively.  For example, DB2 and
> Oracle
> > are two databases that support native sequences.  And, as long as the
> > GeneratedValue Strategy is set to SEQUENCE, I believe this kicks in
> without
> > having to set openjpa.Sequence to "native".
> >
> > Since you are looking to create a new dictionary for Ingres, this would
> > explain why you have to set the openjpa.Sequence property to get the
> desired
> > effect.
> >
> > Can you do any experimentation to verify this?  We may need to update our
> > documentation or javadoc to make this clearer.
> >
> > Kevin
> >
> > On Mon, Jul 27, 2009 at 11:36 AM, Alan Raison <
> Alan.Raison@luminary.co.uk>wrote:
> >
> > > Hi all
> > >
> > > I've been looking at the sequence support in DBDictionary and extending
> > > it for Ingres.  Ingres supports native sequences, but it seems that by
> > > default, OpenJPA prefers to use the OPENJPA_SEQUENCE_TABLE for internal
> > > sequence numbering.  Setting openjpa.Sequence=native changes this to
> use
> > > the native sequences.
> > >
> > > Is there a way/would it be desirable to set a preference for native
> > > sequences in the DB Dictionary?  I don't see this in any other
> > > dictionary, so I assume it's not desirable.  Perhaps this is so the
> > > schema is predictable?
> > >
> > > Thanks
> > >
> > > Alan
> > >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message