cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Joseph P. Berglund" <joey_bergl...@yahoo.com>
Subject Re: non meaningful pk philosophy, and composite pk question
Date Fri, 17 Dec 2010 23:01:11 GMT
Andrus, Steve,

Thank you, this is exactly the information I was looking for. 

Regards,
joey b.
--- On Fri, 12/17/10, Steve Springett <steve@springett.us> wrote:

> From: Steve Springett <steve@springett.us>
> Subject: Re: non meaningful pk philosophy, and composite pk question
> To: user@cayenne.apache.org
> Date: Friday, December 17, 2010, 4:45 PM
> Joey,
> 
> Additionally, I have typically employed the use of the UUID
> object to add
> support for secondary keys that are guaranteed to be
> unique. This approach
> seems to work well for web apps where I need a unique key
> for some record.
> 
> --Steve
> 
> 
> 
> On Fri, Dec 17, 2010 at 1:23 PM, Andrus Adamchik <andrus@objectstyle.org>wrote:
> 
> > Hi Joey,
> >
> >
> > On Dec 17, 2010, at 9:57 PM, Joseph P. Berglund
> wrote:
> > > I am new to cayenne, and am enjoying it
> immensely! A few questions-
> > >
> > > A1) I understand that the use of automatically
> generated, non-meaningful
> > primary keys is one of the philosophies supported by
> cayenne.
> >
> > Yes.
> >
> > > In this instance, what is the best practice
> method of referring to a row
> > in a web based application when I do not have direct
> access to the primary
> > key?
> > >
> > > I am assuming that I should create a UNIQUE
> attribute, like "name", that
> > I can use to refer to that row, but I want to make
> sure that is the right
> > track.
> > >
> > > A2) If that is the case, are there any plans to
> implement easy access to
> > the object through the data context / data object
> without an expression (and
> > without me writing it in my generic wrapper object)?
> I.E. it would be nice
> > if unique, non-pk rows could be access from the object
> itself... (I.e. when
> > I need to grab a user name, performing User user =
> User.forName("joe") would
> > rock my socks)
> >
> > In general there isn't a natural second unique column
> in a table (the
> > opposite would be a special case IMO). So Cayenne
> doesn't try to address
> > this directly, leaving it up to the users to write
> such a "secondary PK"
> > lookup method if they adopt such pattern in their
> design.
> >
> > > B) Much of the data I am dealing with I have
> defined with composite
> > primary keys. With web applications, this involves me
> passing each key
> > individually in an HTTP request. Is there any easy way
> I can pass a record
> > identity for a composite primary key.? I have looked
> at the ObjectID, but
> > from what I have seen, serializing/deserializing this
> requires more overhead
> > than I am comfortable with as I dont need a specific
> reference to the
> > ObjectID class, but to the row the class is
> identifying.
> >
> > IIRC there were a few third-party implementations of
> this functionality,
> > usually attached to some frontend framework. Not so
> long ago I implemented
> > yet another one, available in a "sandbox" area of the
> Cayenne code repo:
> >
> > http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-mixin/trunk/
> >
> > more specifically:
> >
> >
> > http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-mixin/trunk/src/main/java/org/apache/cayenne/mixin/uuid/UuidCoder.java
> >
> > http://svn.apache.org/repos/asf/cayenne/sandbox/cayenne-mixin/trunk/src/main/java/org/apache/cayenne/mixin/ref/ReferenceableHandler.java
> >
> > The whole "cayenne-mixin" module idea is about
> building commonly-used
> > extensions of Cayenne, but the idea of a
> "referenceable" object is generic
> > enough, so it has a chance to be moved to the
> framework core in the future.
> > In the meantime you can copy this code and adapt for
> your app needs as you
> > wish.
> >
> > Andrus
> >
> >
> >
> 


      

Mime
View raw message