Hi,
I'm a bit stumped on this one (I'm using PB with rc4 and dynamic proxies inside
JBoss).
I have a non-decomposed m:n mapping of two extended classes and am trying to implement
auto-update for one side of the relationship. No matter what I try in the mapping
file I keep getting this error when I try to do a broker.store of an object containing
one object on the other side of the relationship:
20:23:37,671 INFO [STDOUT] [org.apache.ojb.broker.accesslayer.JdbcAccessImpl]
ERROR:
20:23:37,681 INFO [STDOUT] SQLException during the execution of the Update SQL
query (for a moos.ssds.model.ProcessRun): [POLYP]Violation of PRIMARY KEY constraint
'PK_DataProducerInput'. Cannot insert duplicate key in object 'DataProducerInput'.
20:23:37,681 INFO [STDOUT] [POLYP]Violation of PRIMARY KEY constraint
'PK_DataProducerInput'. Cannot insert duplicate key in object 'DataProducerInput'.
I've followed the suggestions in tutorial3.html#mapping%20m:n%20associations, yet the
trace of SQL executed on my server is:
exec sp_prepare @P1 output, N'@p1 bigint,@p2 bigint', N'INSERT INTO
DataProducerInput (DataContainerID_FK,DataProducerID_FK) VALUES (@p1,@p2)'
select @P1
go
exec sp_execute 28, 1621, 1847
go
exec sp_prepare @P1 output, N'@p1 bigint,@p2 bigint', N'INSERT INTO
DataProducerInput (DataProducerID_FK,DataContainerID_FK) VALUES (@p1,@p2)'
select @P1
go
exec sp_execute 30, 1847, 1621
go
It seems that the other side of the relationship is trying to be persisted to the
association table (DataProducerInput), even though auto-update is set to "false" for
the reverse side collection.
These are the relevant parts of my repository_user.xml file (following the suggestions
in tutorial 3). The forward collection descriptor is the same for the super class and
the sub class:
<collection-descriptor
name="inputs"
element-class-ref="model.DataContainer"
indirection-table="DataProducerInput"
auto-retrieve="true"
auto-update="true"
>
<fk-pointing-to-this-class column="DataProducerID_FK"/>
<fk-pointing-to-element-class column="DataContainerID_FK"/>
</collection-descriptor>
The reverse collection descriptor is also the same for the super and sub classes:
<collection-descriptor
name="consumers"
element-class-ref="model.DataProducer"
indirection-table="DataProducerInput"
auto-retrieve="true"
auto-update="false"
>
<fk-pointing-to-this-class column="DataContainerID_FK"/>
<fk-pointing-to-element-class column="DataProducerID_FK"/>
</collection-descriptor>
If I remove the latter collection-description then the second insert to the
association table doesn't happen and the auto-update works. Can anyone tell me what
might be wrong here?
Thanks in advance,
Mike
--
Mike McCann (mccann at mbaridotorg)
Monterey Bay Aquarium Research Institute
7700 Sandholdt Road
Moss Landing, CA 95039-9644
Voice: (831) 775-1769 Fax: (831) 775-1646 http://www.mbari.org/rd/iag.htm
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]