This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi all,
I have a model with, among others, two tables "daadraft" and "daariferimento",
CREATE TABLE `six`.`daadraft` ( `Id` bigint(20) unsigned NOT NULL auto_increment, `TipoMessaggio` varchar(2) default NULL, `TipoDestinazione` varchar(2) default NULL, `UnitaMisuraDurataTrasporto` varchar(2) default NULL, `DurataTrasporto` smallint(5) unsigned default NULL, `ResponsabileTrasporto` varchar(2) default NULL, `FlagInvioDiffertito` tinyint(1) unsigned default NULL, `SpeditoreId` bigint(20) unsigned default NULL, `LuogoSpedizioneId` bigint(20) unsigned default NULL, `UfficioSpedizioneCodice` varchar(8) default NULL, `UfficioSpedizione` varchar(50) default NULL, `AutoritaFiscaleCodice` varchar(8) default NULL, `AutoritaFiscale` varchar(50) default NULL, `DestinatarioId` bigint(20) unsigned default NULL, `DestinatarioPaeseCodice` varchar(2) default NULL, `DestinatarioPaese` varchar(50) default NULL, `CertificatoEsenzione` varchar(255) default NULL, `LuogoDestinazioneId` bigint(20) unsigned default NULL, `UfficioDestinazioneCodice` varchar(8) default NULL, `UfficioDestinazione` varchar(50) default NULL, `ModalitaTrasporto` varchar(2) default NULL, `AziendaTrasportoId` bigint(20) unsigned default NULL, `PrimoTrasportatoreId` bigint(20) unsigned default NULL, `NumeroDocumento` varchar(35) default NULL, `DataDocumento` date default NULL, `TipoSpeditore` varchar(2) default NULL, `DataSpedizione` datetime default NULL, `TipoGaranti` varchar(4) default NULL, `SpeditoreGaranziaId` bigint(20) unsigned default NULL, `DestinatarioGaranziaId` bigint(20) unsigned default NULL, `TrasportatoreGaranziaId` bigint(20) unsigned default NULL, `ProprietarioGaranziaId` bigint(20) unsigned default NULL, `CreatedOn` datetime default NULL, `UpdatedOn` datetime default NULL, `CodicePratica` varchar(22) default NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB;
CREATE TABLE `six`.`daariferimento` ( `Id` bigint(20) unsigned NOT NULL auto_increment, `Discriminatore` varchar(20) NOT NULL, `Codice` varchar(35) default NULL, `Denominazione` varchar(182) default NULL, `Indirizzo` varchar(65) default NULL, `Civico` varchar(16) default NULL, `CAP` varchar(10) default NULL, `Citta` varchar(50) default NULL, `Lingua` varchar(2) default NULL, `CreatedOn` datetime default NULL, `UpdatedOn` datetime default NULL, PRIMARY KEY (`Id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
"daatraft" maps to an entity,
"daariferimento" maps to serveral entities trhough single table inheritance using the "discriminatore" column. The mapped entities are: "Speditore" with discriminator column set to "Speditore", "Destinatario" with discriminator column set to "Destinatario", "AziendaTrasporto" with discriminator column set to "AziendaTrasporto",
daadraft has one-to-one relationship with each of this derived entities.
All works well until I set the eager load attributes on the "daariferimento" derived tables. I soon as I do that the generated sql for the "Speditore" entity become:
SELECT daariferimento.Id, daariferimento.Cap, daariferimento.Citta, daariferimento.Civico, daariferimento.Codice, daariferimento.CreatedOn, daariferimento.Denominazione, daariferimento.Discriminatore, daariferimento.Indirizzo, daariferimento.Lingua, daariferimento.UpdatedOn FROM daariferimento WHERE (EXISTS ( SELECT Daadraft.* FROM Daadraft WHERE Daadraft.AziendaTrasportoId = daariferimento.Id AND Daadraft.Id = 2 ) AND daariferimento.Discriminatore = 'Speditore')
As you can see the discriminator column value is set correctly to 'Speditore' but the foreign key is checked against "Daadraft.AziendaTrasportoId" instead of "Daadraft.SpeditoreId".
All the column names are specified correctly in the model ("SpeditoreId" for Speditore ecc). I'm I missing something??? |
|
|
I'm having trouble reproducing this. Could you provide me with your LightSpeed model (the C# or VB classes, no need for the .lsmodel) please? Thanks! |
|
|
Never mind. I've got it repro-ing here now -- sorry about the false alarm. |
|
|
Thanks for reporting this issue. It looks like you have multiple separate one-to-one associations to Daadraft declared, one in each of the derived classes (e.g. Speditore, AziendaTrasporto, etc.). Is that correct? If so, there will be a candidate fix for this in the next nightly build (dated 5 Aug 2010, available from about 1500 GMT). Please let us know if you still see the problem when using this nightly build. Thanks! |
|
|
Hi,
Yes, that's exactly how my model is defined.
Thanks for the quick fix. |
|