Re: Can I getting a unique ID from a select

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Timasmith <timasmith(at)hotmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Can I getting a unique ID from a select
Date: 2007-03-04 12:44:37
Message-ID: 20070304124437.GA31004@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Mar 03, 2007 at 18:12:19 -0600,
Bruno Wolff III <bruno(at)wolff(dot)to> wrote:
> On Thu, Mar 01, 2007 at 06:16:02 -0800,
> Timasmith <timasmith(at)hotmail(dot)com> wrote:
> > I am using hibernate, using a view like a read only table and I need a
> > primary key each time a select is issued.
> >
> > create view myview as
> > select rownum, t1.field, t2.field
> > from tableOne t1, tableTwo t2
> > where t1.key = t2.fkey
> >
> > select * from myview
> >
> > But what I really need is
> >
> > select makemeauniquekey, t1.field, t2.field
> > ...
>
> Is there some reason you can't use the join key?

To expand on this, if you are joining on fields that will return only
one record for each value, you should still be able to make a primary
key for the returned records using a combination of the primary keys
of both records being joined. If hibernate only works with primary keys
consisting of one column, than you can create a new field using a function
of the primary keys of the records being joined.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Garry Saddington 2007-03-04 12:47:05 date format
Previous Message Shane Ambler 2007-03-04 10:47:15 Re: Interface to posgresql