You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by 乔木 <qi...@gmail.com> on 2009/03/29 03:24:02 UTC

Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

I don't want openjpa to create that table

-- 
Best wishes,
乔木
MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
Department of Computer Science and Technology, Xi’an Jiaotong University
TEL: 15991676983
E-mail: qiaomuf@gmail.com

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

Posted by 乔木 <qi...@gmail.com>.
Thanks very mush. Really helps a lot ^_^

2009/4/1 Jeremy Bauer <te...@gmail.com>

> Are you constrained to using an integral column type for the ID?  If not,
> another option may be to use an OpenJPA UUID-based generator[1] with a
> string id column.  These generators create a value within OpenJPA provider
> and have no database-specific dependencies. For example:
>
> ...
>    @Id
>    @GeneratedValue(generator="uuid-hex")
>    private String id;
> ...
>
> [1]
>
> http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_meta_field.html#jpa_overview_meta_gen
>
> -Jeremy
>
>
> 2009/3/31 Michael Dick <mi...@gmail.com>
>
> > Hi,
> >
> > Disclosure I'm not an expert on SQLServer, and I don't have access to a
> > SQLServer instance to test with at the moment.
> >
> > It looks like SQLServer doesn't support sequences but there are some
> > alternatives besides an IDENTITY column [1]. From a JPA standpoint I
> think
> > you'd annotate the field in the same manner as you would when using
> > IDENTITY
> > though.
> >
> > [1]
> >
> >
> http://www.sqljunkies.ddj.com/Article/4067A1B1-C31C-4EAF-86C3-80513451FC03.scuk
> >
> > OTOH this is probably the same thing you're trying to avoid by not having
> > IDENTITY columns. If that's the case then you'll have to generate a table
> > (similar to OPENJPA_SEQUENCE_TABLE) or manually manage the primary key
> > column in your app.
> >
> > Hope this helps,
> > -mike
> >
> > 2009/3/29 乔木 <qi...@gmail.com>
> >
> > > SQL Server (without IDENTITY Column)
> > >
> > > 2009/3/29 Paul Copeland <te...@jotobjects.com>
> > >
> > > > Your alternatives depend on the database you are using. What
> database?
> > > >
> > > > On 3/28/2009 6:24 PM, 乔木 wrote:
> > > > > I don't want openjpa to create that table
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Best wishes,
> > > 乔木
> > > MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
> > > Department of Computer Science and Technology, Xi’an Jiaotong
> University
> > > TEL: 15991676983
> > > E-mail: qiaomuf@gmail.com
> > >
> >
>



-- 
Best wishes,
乔木
MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
Department of Computer Science and Technology, Xi’an Jiaotong University
TEL: 15991676983
E-mail: qiaomuf@gmail.com

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

Posted by Jeremy Bauer <te...@gmail.com>.
Are you constrained to using an integral column type for the ID?  If not,
another option may be to use an OpenJPA UUID-based generator[1] with a
string id column.  These generators create a value within OpenJPA provider
and have no database-specific dependencies. For example:

...
    @Id
    @GeneratedValue(generator="uuid-hex")
    private String id;
...

[1]
http://openjpa.apache.org/builds/latest/docs/manual/jpa_overview_meta_field.html#jpa_overview_meta_gen

-Jeremy


2009/3/31 Michael Dick <mi...@gmail.com>

> Hi,
>
> Disclosure I'm not an expert on SQLServer, and I don't have access to a
> SQLServer instance to test with at the moment.
>
> It looks like SQLServer doesn't support sequences but there are some
> alternatives besides an IDENTITY column [1]. From a JPA standpoint I think
> you'd annotate the field in the same manner as you would when using
> IDENTITY
> though.
>
> [1]
>
> http://www.sqljunkies.ddj.com/Article/4067A1B1-C31C-4EAF-86C3-80513451FC03.scuk
>
> OTOH this is probably the same thing you're trying to avoid by not having
> IDENTITY columns. If that's the case then you'll have to generate a table
> (similar to OPENJPA_SEQUENCE_TABLE) or manually manage the primary key
> column in your app.
>
> Hope this helps,
> -mike
>
> 2009/3/29 乔木 <qi...@gmail.com>
>
> > SQL Server (without IDENTITY Column)
> >
> > 2009/3/29 Paul Copeland <te...@jotobjects.com>
> >
> > > Your alternatives depend on the database you are using. What database?
> > >
> > > On 3/28/2009 6:24 PM, 乔木 wrote:
> > > > I don't want openjpa to create that table
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Best wishes,
> > 乔木
> > MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
> > Department of Computer Science and Technology, Xi’an Jiaotong University
> > TEL: 15991676983
> > E-mail: qiaomuf@gmail.com
> >
>

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

Posted by Michael Dick <mi...@gmail.com>.
Hi,

Disclosure I'm not an expert on SQLServer, and I don't have access to a
SQLServer instance to test with at the moment.

It looks like SQLServer doesn't support sequences but there are some
alternatives besides an IDENTITY column [1]. From a JPA standpoint I think
you'd annotate the field in the same manner as you would when using IDENTITY
though.

[1]
http://www.sqljunkies.ddj.com/Article/4067A1B1-C31C-4EAF-86C3-80513451FC03.scuk

OTOH this is probably the same thing you're trying to avoid by not having
IDENTITY columns. If that's the case then you'll have to generate a table
(similar to OPENJPA_SEQUENCE_TABLE) or manually manage the primary key
column in your app.

Hope this helps,
-mike

2009/3/29 乔木 <qi...@gmail.com>

> SQL Server (without IDENTITY Column)
>
> 2009/3/29 Paul Copeland <te...@jotobjects.com>
>
> > Your alternatives depend on the database you are using. What database?
> >
> > On 3/28/2009 6:24 PM, 乔木 wrote:
> > > I don't want openjpa to create that table
> > >
> > >
> >
> >
>
>
> --
> Best wishes,
> 乔木
> MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
> Department of Computer Science and Technology, Xi’an Jiaotong University
> TEL: 15991676983
> E-mail: qiaomuf@gmail.com
>

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

Posted by 乔木 <qi...@gmail.com>.
SQL Server (without IDENTITY Column)

2009/3/29 Paul Copeland <te...@jotobjects.com>

> Your alternatives depend on the database you are using. What database?
>
> On 3/28/2009 6:24 PM, 乔木 wrote:
> > I don't want openjpa to create that table
> >
> >
>
>


-- 
Best wishes,
乔木
MOE KLINNS Lab and SKLMS Lab, Xi'an Jiaotong University
Department of Computer Science and Technology, Xi’an Jiaotong University
TEL: 15991676983
E-mail: qiaomuf@gmail.com

Re: Could I generate ID without the OPENJPA_SEQUENCE_TABLE table?

Posted by Paul Copeland <te...@jotobjects.com>.
Your alternatives depend on the database you are using. What database?

On 3/28/2009 6:24 PM, 乔木 wrote:
> I don't want openjpa to create that table
>
>