Hallo Armin,
1) Nothing changed in mapping for Supplier
2) "fk_bpid" is the primary key for this class/table, but it is also the foreign key
of the 1:1 relationship to BusinessPartner
3) I'm not quite sure if I have to declare a field-descriptor for "SUPPLIERID",
because in the docs ("Advanced O/R") nothing is mentioned.
4) The SQL-Error occures just after I had changed the mapping of SellableItem,
Product, ServiceContract as Wally said, before insert was not the problem. So perhaps
the mapping of the Products is the problem !?
Thanks,
Stephan
-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 17, 2003 10:29 AM
To: OJB Users List
Subject: Re: Mapping problem
Hi Stephan,
hmm, how does your mapping for
demo.myshop.model.ojb2.Supplier
look like (nothing changed from your first post)?
From your first post
>> <class-descriptor
>> class="demo.myshop.model.ojb2.Supplier"
>> table="OJB_SUPPLIER">
>> <field-descriptor
>> name="fk_bpid"
>> column="FK_BPID"
>> jdbc-type="INTEGER"
>> primarykey="true"
Why you set primarykey 'true' for this anonymous field?
>> autoincrement="false"
>> access="anonymous"/>
>>
>> <field-descriptor
>> name="shippingCost"
>> column="SHIPPINGCOST"
>> jdbc-type="INTEGER"/>
>>
>> <reference-descriptor
>> name="businessPartner"
>> class-ref="demo.myshop.model.ojb2.BusinessPartner">
>> <foreignkey field-ref="fk_bpid"/>
>> </reference-descriptor>
>>
>> <collection-descriptor
>> name="items"
>> element-class-ref="demo.myshop.model.ojb2.SellableItem"
>> auto-retrieve="true"
>> auto-update="true"
>> indirection-table="OJB_SUPPLIER_ITEM">
>> <fk-pointing-to-this-class column="SUPPLIERID"/>
Can't see a field-descriptor with SUPPLIERID column in this
class-descriptor.
>> <fk-pointing-to-element-class column="ITEMID"/>
>> </collection-descriptor>
>>
>> </class-descriptor>
regards,
Armin
Stephan Wannenwetsch wrote:
> Hi Armin,
>
> I checked it but nothing changed. I also removed all data from the
> DB-tables but nothing changed, too.
>
> Thanks,
> Stephan
>
> -----Original Message-----
> From: Armin Waibel [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 15, 2003 6:03 PM
> To: OJB Users List
> Subject: Re: Mapping problem
>
>
> Hi,
>
> maybe sequence-name "algorithm" had problems. Try to remove related
> row in OJB_HL_SEQ table (name of the first found extent class table name). You can
> do a quick check using SequenceManagerInMemoryImpl in your test.
> If your test pass, it's a H/L sequence manager problem.
>
> regards,
> Armin
>
> Stephan Wannenwetsch wrote:
>
>>Hi Wally,
>>
>>I'm using the following sequence-manager:
>>
>><sequence-manager
>>className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>> <attribute attribute-name="grabSize" attribute-value="20"/>
>> <attribute attribute-name="autoNaming" attribute-value="true"/>
>> <attribute attribute-name="globalSequenceId" attribute-value="false"/>
>> <attribute attribute-name="globalSequenceStart"
>>attribute-value="10000"/> </sequence-manager>
>>
>>Stephan
>>
>>
>>-----Original Message-----
>>From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
>>Sent: Monday, December 15, 2003 5:35 PM
>>To: OJB Users List
>>Subject: RE: Mapping problem
>>
>>
>>Hi Stephan,
>>
>>Sounds like a sequence manager configuration problem. A PK must be
>>unique within an extent hierarchy, so you cannot use an IDENTITY
>>column for a PK. What sequence manager are you using?
>>
>>Wally
>>
>>
>>
>>-----Original Message-----
>>From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED]
>>Sent: Monday, December 15, 2003 10:16 AM
>>To: OJB Users List
>>Subject: RE: Mapping problem
>>
>>
>>Hallo Wally,
>>
>>I've changed the mapping into:
>> <class-descriptor class="demo.myshop.model.ojb2.SellableItem">
>> <extent-class class-ref="demo.myshop.model.ojb2.ServiceContract" />
>> <extent-class class-ref="demo.myshop.model.ojb2.Product" />
>> </class-descriptor>
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.ServiceContract"
>> table="OJB_SELLABLEITEM">
>>
>> <field-descriptor
>> name="itemId"
>> column="ITEMID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"/>
>>
>> <field-descriptor
>> name="ojbConcreteClass"
>> column="CLASS_NAME"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="description"
>> column="DESCRIPTION"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="price"
>> column="PRICE"
>> jdbc-type="INTEGER"/>
>>
>> <field-descriptor
>> name="period"
>> column="PERIOD"
>> jdbc-type="INTEGER"/>
>>
>> <collection-descriptor
>> name="suppliers"
>> element-class-ref="demo.myshop.model.ojb2.Supplier"
>> auto-retrieve="true"
>> auto-update="true"
>> indirection-table="OJB_SUPPLIER_ITEM">
>> <fk-pointing-to-this-class column="ITEMID"/>
>> <fk-pointing-to-element-class column="SUPPLIERID"/>
>> </collection-descriptor>
>> </class-descriptor>
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.Product"
>> table="OJB_SELLABLEITEM">
>>
>> <field-descriptor
>> name="itemId"
>> column="ITEMID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"/>
>>
>> <field-descriptor
>> name="ojbConcreteClass"
>> column="CLASS_NAME"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="description"
>> column="DESCRIPTION"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="price"
>> column="PRICE"
>> jdbc-type="INTEGER"/>
>>
>> <field-descriptor
>> name="weight"
>> column="WEIGHT"
>> jdbc-type="INTEGER"/>
>> <collection-descriptor
>> name="suppliers"
>> element-class-ref="demo.myshop.model.ojb2.Supplier"
>> auto-retrieve="true"
>> auto-update="true"
>> indirection-table="OJB_SUPPLIER_ITEM">
>> <fk-pointing-to-this-class column="ITEMID"/>
>> <fk-pointing-to-element-class column="SUPPLIERID"/>
>> </collection-descriptor>
>> </class-descriptor>
>>
>>
>>
>>But now I get an error when I store a supplier (primary key - error,
>>pk not unique in OJB_SUPPLIER_ITEM, can't insert). Transaction started
>>
>>
>>[org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: SQLException
>>during the execution of the Update SQL query (for a
>>demo.myshop.model.ojb2.Supplier): [Microsoft][SQLServer 2000 Driver for
>>JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschr�nkung 'PK_OJB_SUPPLIER_ITEM'. Ein
>>doppelter Schl�ssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingef�gt werden.
>>[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Verletzung der PRIMARY
>>KEY-Einschr�nkung 'PK_OJB_SUPPLIER_ITEM'. Ein doppelter Schl�ssel kann
>
> i n das OJB_SUPPLIER_ITEM-Objekt nicht eingef�gt werden.
>
>>java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
>>JDBC][SQLServer]Verletzung der PRIMARY KEY-Einschr�nkung 'PK_OJB_SUPPLIER_ITEM'. Ein
>>doppelter Schl�ssel kann in das OJB_SUPPLIER_ITEM-Objekt nicht eingef�gt werden.
>> at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
>> at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown
>>Source)
>>
>>Some more ideas ???
>>
>>Thanks,
>>Stephan
>>
>>
>>
>>
>>
>>
>>
>>
>>-----Original Message-----
>>From: Gelhar, Wallace Joseph [mailto:[EMAIL PROTECTED]
>>Sent: Monday, December 15, 2003 3:44 PM
>>To: OJB Users List
>>Subject: RE: Mapping problem
>>
>>
>>Hi Stephan,
>>
>>OJB does not support class descriptor inheritance for <extent-class>
>>elements. Try moving your "common" fields from Sellable item into
>>each of the concrete class descriptors and making Sellable item
>>non-concrete (it is only an interface after all) such as:
>>
>><class-descriptor class="demo.myshop.model.ojb2.SellableItem" >
>> <extent-class class-ref="demo.myshop.model.ojb2.ServiceContract"
>>/>
>> <extent-class class-ref="demo.myshop.model.ojb2.Product" />
>></class-descriptor>
>>
>>Hope this helps.
>>
>>Wally
>>
>>-----Original Message-----
>>From: Stephan Wannenwetsch [mailto:[EMAIL PROTECTED]
>>Sent: Monday, December 15, 2003 4:16 AM
>>To: [EMAIL PROTECTED]
>>Subject: Mapping problem
>>
>>
>>Hallo,
>>
>>I've got a problem retrieving objects from a m:n relationship:
>>
>>Object model:
>>
>>class Supplier;
>>=>Collection items;
>>
>>Interface SellableItem;
>>=>Collection suppliers;
>>
>>class Product implements SellableItem;
>>=> Collection suppliers;
>>
>>class ServiceContract implements SellableItem;
>>=> Collection suppliers;
>>
>>Of course there are some more attributes in each class with the
>>corresponding getter and setters.
>>
>>I use an itermediate table OJB_SUPPLIER_ITEM to realise the m:n
>>relationship.
>>
>>Every thing works fine coming from the supplier side and retriving the
>>related items of a supplier but I'm not able to retrieve the related
>>suppliers of an item.
>>
>>I hope someone can help me.
>>
>>Thanks,
>>Stephan
>>
>>Mapping:
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.Supplier"
>> table="OJB_SUPPLIER">
>> <field-descriptor
>> name="fk_bpid"
>> column="FK_BPID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="false"
>> access="anonymous"/>
>>
>> <field-descriptor
>> name="shippingCost"
>> column="SHIPPINGCOST"
>> jdbc-type="INTEGER"/>
>>
>> <reference-descriptor
>> name="businessPartner"
>> class-ref="demo.myshop.model.ojb2.BusinessPartner">
>> <foreignkey field-ref="fk_bpid"/>
>> </reference-descriptor>
>>
>> <collection-descriptor
>> name="items"
>> element-class-ref="demo.myshop.model.ojb2.SellableItem"
>> auto-retrieve="true"
>> auto-update="true"
>> indirection-table="OJB_SUPPLIER_ITEM">
>> <fk-pointing-to-this-class column="SUPPLIERID"/>
>> <fk-pointing-to-element-class column="ITEMID"/>
>> </collection-descriptor>
>>
>> </class-descriptor>
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.SellableItem"
>> table="OJB_SELLABLEITEM">
>>
>> <extent-class class-ref="demo.myshop.model.ojb2.ServiceContract"
>>/>
>> <extent-class class-ref="demo.myshop.model.ojb2.Product" />
>>
>> <field-descriptor
>> name="itemId"
>> column="ITEMID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"/>
>>
>> <field-descriptor
>> name="ojbConcreteClass"
>> column="CLASS_NAME"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="description"
>> column="DESCRIPTION"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="price"
>> column="PRICE"
>> jdbc-type="INTEGER"/>
>>
>> <collection-descriptor
>> name="suppliers"
>> element-class-ref="demo.myshop.model.ojb2.Supplier"
>> auto-retrieve="true"
>> auto-update="true"
>> indirection-table="OJB_SUPPLIER_ITEM">
>> <fk-pointing-to-this-class column="ITEMID"/>
>> <fk-pointing-to-element-class column="SUPPLIERID"/>
>> </collection-descriptor>
>> </class-descriptor>
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.ServiceContract"
>> table="OJB_SELLABLEITEM">
>>
>> <field-descriptor
>> name="itemId"
>> column="ITEMID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"/>
>>
>> <field-descriptor
>> name="ojbConcreteClass"
>> column="CLASS_NAME"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="description"
>> column="DESCRIPTION"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="price"
>> column="PRICE"
>> jdbc-type="INTEGER"/>
>>
>> <field-descriptor
>> name="period"
>> column="PERIOD"
>> jdbc-type="INTEGER"/>
>> </class-descriptor>
>>
>> <class-descriptor
>> class="demo.myshop.model.ojb2.Product"
>> table="OJB_SELLABLEITEM">
>>
>> <field-descriptor
>> name="itemId"
>> column="ITEMID"
>> jdbc-type="INTEGER"
>> primarykey="true"
>> autoincrement="true"/>
>>
>> <field-descriptor
>> name="ojbConcreteClass"
>> column="CLASS_NAME"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="description"
>> column="DESCRIPTION"
>> jdbc-type="VARCHAR"/>
>>
>> <field-descriptor
>> name="price"
>> column="PRICE"
>> jdbc-type="INTEGER"/>
>>
>> <field-descriptor
>> name="weight"
>> column="WEIGHT"
>> jdbc-type="INTEGER"/>
>> </class-descriptor>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]