Re: Strange error message

Pierre Bernard <[email protected]>
Newsgroups gmane.comp.web.webobjects.eof
Message-ID <[email protected]>
Anjo,

> No, I thought the two methods would prevent this from happening: Say 
> your data up to this point does not have duplicate PKs. When you 
> generate the PK, you'd check for Bicycle (max id=10) and Car (max 
> id=11) and return 12 afterwards -> no conflict for the new Bicycle.

True. I thought you were speaking of mapping a legacy database where 
conflicting IDs already exist. Then again the (Oracle) adaptor/plugin 
already uses one single sequence for both entities. It uses 
ROOT_ENTITY_SEQ or ROOT_TABLE_SEQ. I don't recall. I never understood 
why in some situations the sequence is named after the entity and in 
others its named after the table.


> On the other hand, when you fetch a Vehicle with 12 and there is a Car 
> *and* a Bicycle, the Exception would tell you that your data needs a 
> massage...

The catch is that I don't see where you would get such an exception. 
Even if you fetch using a fetch specification you will silently get the 
existing EO unless you set your fetch spec to refresh EOs in which case 
I expect bad things to happen.


> If I get you correctly, then you mean to remove the "toVehicles" 
> relation from the Driver, add a "toCars" and "toBicylces" and add a 
> custom method "toVehicles" which combines them later on?

No, my solution only applies in situations where you have no toVehicles 
relationship in your model. If you do have one you will probably have 
to manually code the parent class an manually maintain the two distinct 
relationships like you explained earlier. A whole lot of work. I would 
however expect that situation to be very uncommon on legacy databases 
as would not be represented by a foreign key in the database. E.g. if 
the Person table had a Vehicle_ID field there would be no way to know 
if it points to the Car or the Bicycle table.

Time to go to bed now. (CET timezone)

Pierre.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.