Oh, the tangled web we weave, when first we practice to deceive... Why isn't it the primary key? Because this id represents a value that's unique in another database, and it's really a foreign key to a database that we don't have access to. A better design would be to use this value as the key to our table, but historically it wasn't done that way so... now I'm going to dummy it up and I'd like it to be unique because it is replicated in our schema and I really don't want collisions.
Another thought was to map the key from the table to the "foreign" key value, but there are problems with the optics of that choice when talking about what I did to the target audience. Sadly, it needs to be a long, so subbing in a uuid, or a string really isn't a good choice. ON the other hand maybe using apache string utils to generate a random large string and then taking the hash of that string might yield something random enough. Thank you all for your assistance. Tony On 2018/05/23 20:53:29, Ken Anderson <[email protected]> wrote: > Is it a child of another object where the numbers would reset, or is it unique throughout the DB? If so, why isn’t it the primary key?> > > > On May 23, 2018, at 4:52 PM, Tony Giaccone <[email protected]> wrote:> > > > > > Imagine I have a field in a persistent object, the field is not the primary> > > key, and I want it to be unique. So the obvious choice to me is to use a> > > sequence value from the db, so that I can avoid trying to calculate a value> > > in java.> > > > > > Is there an easy way to access that sequence value, from java, using> > > Cayenne?> > > > > > > > > Tony> > >
