Combined primary key?

3 views
Skip to first unread message

Arthur

unread,
Nov 23, 2009, 10:18:14 AM11/23/09
to Lift, avan...@gmail.com
Hi all

I can't seem to find a way to use a combined primary key. The use case
I'm looking at would be something like a bug tracker where you can
comment on each bug. Each comment would have a number (only unique
within each bug report). In SQL I'd write something like:

CREATE TABLE bug_comments (
bugid integer REFERENCES bugs (id),
number integer,
comment text,
PRIMARY KEY (bugid, number)
)

I've seen that I can enforce the uniqueness of (bugid, number) with
def dbIndexes = Index (bugid, number) :: super.dbIndexes

I'd like to have the comments numbered 1..n in each bug so they can be
easily referenced. What is the common way to do this in Lift? Should I
try to go that way or would you abandon the combined primary key and
simply use a synthetic primary key with LongKeyedMapper with IdPK?

Thanks for any input.

Yours

Arthur

Ross Mellgren

unread,
Nov 23, 2009, 11:30:38 AM11/23/09
to lif...@googlegroups.com, avan...@gmail.com
I have heard on the list previously that compound primary keys are not
supported by mapper.

-Ross
> --
>
> You received this message because you are subscribed to the Google
> Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=
> .
>
>

David Pollak

unread,
Nov 23, 2009, 11:42:15 AM11/23/09
to lif...@googlegroups.com
On Mon, Nov 23, 2009 at 8:30 AM, Ross Mellgren <dri...@gmail.com> wrote:
I have heard on the list previously that compound primary keys are not
supported by mapper.

That'd be correct.  Please use JPA.
 



--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

Arthur

unread,
Nov 23, 2009, 12:49:59 PM11/23/09
to Lift
On 23 Nov., 17:42, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> On Mon, Nov 23, 2009 at 8:30 AM, Ross Mellgren <dri...@gmail.com> wrote:
> > I have heard on the list previously that compound primary keys are not
> > supported by mapper.
>
> That'd be correct.  Please use JPA.

Thanks Ross and David. Compound primary key, not combined primary key,
that's why I haven't found much. :) In that case I go with a synthetic
primary key.

Regards

Arthur
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=
> > > .
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/liftweb?hl=.
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
Reply all
Reply to author
Forward
0 new messages