Hi Deb,

the declaration of the 1:n relation between Order and CouponSlug is correct. If you copy or serialize CouponSlug objects it's not allowed to declare the 'orderId' field anonymous (only in conjunction with 1:1 references)
http://db.apache.org/ojb/docu/guides/advanced-technique.html#How+do+


If this isn't the problem, please send to my account a test case showing the problem (or a file with detailed pseudo code). Then I will try to setup your problem locally with existing classes in OJB tests suite.

regards,
Armin


Deborah Nunley wrote:
Armin

Did involved objects Order or CouponSlug or Product share their database table with other objects? No - We do not have a product class.

If yes, do you use ojbContrecteClass feature? N/A

Which sequence manager do you use? Our own

Additionally
When we are storing the 2nd product, the "deleted" CouponSlug is showing up in 
the RemovalAwareCollection under ItemsToBeRemoved, but no SQL DELETE call is ever made.

Deb

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Friday, February 18, 2005 12:12 PM
To: OJB Users List
Subject: Re: Persistence question


seems the constraint violation occur when OJB try to store an 1:n relation of the order object. Does CouponSlug inherit from Product or is it used in a separate relation of Order? Is it possible to post the class-descriptor for Order, Product and CouponSlug?
Did involved objects Order or CouponSlug or Product share their database table with other objects? If yes, do you use ojbContrecteClass feature?
Which sequence manager do you use?


regards,
Armin


Deborah Nunley wrote:

db-ojb-1.0.1 PersistenceBroker

INFO: Rollback was called, do rollback on current connection [EMAIL PROTECTED]
org.apache.ojb.broker.KeyConstraintViolatedException: SQL failure while insert object 
data for class com.valpak.productorder.couponslug.CouponSlug, PK of the given object 
is [ couponSlugId=665058], object was [EMAIL 
PROTECTED],sequenceId=1,address=[],[EMAIL 
PROTECTED],offerText=offer,additionalDisclaimerText=,[EMAIL 
PROTECTED],sequenceId=1,[EMAIL PROTECTED],disclaimerDescription= ,disclaimerText=One 
coupon per customer.,lastUpdate=Fri Sep 18 00:00:00 EDT 
1998]]],productImage=[],expirationDate=<null>,startDate=Tue Aug 31 00:00:00 EDT 
2004,endDate=Tue Aug 31 00:00:00 EDT 
2004,sequenceId=1,printLimit=0,displayExpiration=true]],webLink=[],productImage=[],printable=true,displayRanking=40000,backgroun


[EMAIL PROTECTED],colorName=<null>,hexCode=<null>],[EMAIL PROTECTED],[EMAIL PROTECTED],couponSlugTypeName=<null>]], exception message is [Attempt to insert duplicate key row in object 'Coupon_Slugs' with unique index 'PK_COUPON_SLUGS'

]
        at 
org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeAndLinkOneToMany(Unknown 
Source)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeCollections(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeAndLinkOneToOne(Unknown 
Source)
        at 
org.apache.ojb.broker.core.PersistenceBrokerImpl.storeReferences(Unknown Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at org.apache.ojb.broker.core.PersistenceBrokerImpl.store(Unknown 
Source)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown 
Source)
        at org.apache.ojb.broker.core.DelegatingPersistenceBroker.store(Unknown 
Source)
        at 
com.valpak.persistence.ojb.OJBPersistenceServiceImpl.storeObject(OJBPersistenceServiceImpl.java:96)
        at 
com.valpak.vpcoladminservice.VPColAdminServiceImpl.storeOrder(VPColAdminServiceImpl.java:119)
        at 
com.valpak.vpcoladmin.action.ProcessOrder.processSave(ProcessOrder.java:176)
        at 
com.valpak.vpcoladmin.action.ProcessOrder.executeAction(ProcessOrder.java:125)
        at 
com.valpak.vpcoladmin.action.VPColAdminBaseAction.execute(VPColAdminBaseAction.java:43)
        at 
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
        at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
        at 
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at 
com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1650)
        at 
com.newatlanta.servletexec.SERequestDispatcher.forwardServlet(SERequestDispatcher.java:274)
        at 
com.newatlanta.servletexec.SERequestDispatcher.forward(SERequestDispatcher.java:191)
        at 
com.newatlanta.servletexec.ApplicationInfo.processApplRequest(ApplicationInfo.java:1313)
        at 
com.newatlanta.servletexec.ServerHostInfo.processApplRequest(ServerHostInfo.java:958)
        at 
com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1206)
        at 
com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1056)
        at 
com.newatlanta.sedebugger.Responder.processServletRequest(Responder.java:269)
        at com.newatlanta.sedebugger.Responder.run(Responder.java:92)
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Attempt to insert duplicate 
key row in object 'Coupon_Slugs' with unique index 'PK_COUPON_SLUGS'

        at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2738)
        at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:2069)
        at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
        at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
        at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
        at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1667)
        at 
com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1650)
        at 
com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:104)
        ... 36 more
com.valpak.exceptions.StoreException: SQL failure while insert object data for class 
com.valpak.productorder.couponslug.CouponSlug, PK of the given object is [ 
couponSlugId=665058], object was [EMAIL PROTECTED],sequenceId=1,address=[],[EMAIL 
PROTECTED],offerText=offer,additionalDisclaimerText=,[EMAIL 
PROTECTED],sequenceId=1,[EMAIL PROTECTED],disclaimerDescription= ,disclaimerText=One 
coupon per customer.,lastUpdate=Fri Sep 18 00:00:00 EDT 
1998]]],productImage=[],expirationDate=<null>,startDate=Tue Aug 31 00:00:00 EDT 
2004,endDate=Tue Aug 31 00:00:00 EDT 
2004,sequenceId=1,printLimit=0,displayExpiration=true]],webLink=[],productImage=[],printable=true,displayRanking=40000,background=com.valpak.col


[EMAIL PROTECTED],colorName=<null>,hexCode=<null>],[EMAIL PROTECTED],[EMAIL PROTECTED],couponSlugTypeName=<null>]], exception message is [Attempt to insert duplicate key row in object 'Coupon_Slugs' with unique index 'PK_COUPON_SLUGS'

][org.apache.ojb.broker.core.PersistenceBrokerImpl] DEBUG: PB.close was called: 
[EMAIL PROTECTED]

        at 
com.valpak.persistence.ojb.OJBPersistenceServiceImpl.storeObject(OJBPersistenceServiceImpl.java:104)
        at 
com.valpak.vpcoladminservice.VPColAdminServiceImpl.storeOrder(VPColAdminServiceImpl.java:119)
        at 
com.valpak.vpcoladmin.action.ProcessOrder.processSave(ProcessOrder.java:176)
        at 
com.valpak.vpcoladmin.action.ProcessOrder.executeAction(ProcessOrder.java:125)
        at 
com.valpak.vpcoladmin.action.VPColAdminBaseAction.execute(VPColAdminBaseAction.java:43)
        at 
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
        at 
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
        at 
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at 
com.newatlanta.servletexec.ServletExec.CallServletService(ServletExec.java:1650)
        at 
com.newatlanta.servletexec.SERequestDispatcher.forwardServlet(SERequestDispatcher.java:274)
        at 
com.newatlanta.servletexec.SERequestDispatcher.forward(SERequestDispatcher.java:191)
        at 
com.newatlanta.servletexec.ApplicationInfo.processApplRequest(ApplicationInfo.java:1313)
        at 
com.newatlanta.servletexec.ServerHostInfo.processApplRequest(ServerHostInfo.java:958)[2005-02-18
 10:52:30,231] com.valpak.vpcoladmin.action.VPColAdminBaseAction - 
com.valpak.exceptions.StoreException: SQL failure while insert object data for class 
com.valpak.productorder.couponslug.CouponSlug, PK of the given object is [ 
couponSlugId=665058], object was [EMAIL PROTECTED],sequenceId=1,address=[],[EMAIL 
PROTECTED],offerText=offer,additionalDisclaimerText=,[EMAIL 
PROTECTED],sequenceId=1,[EMAIL PROTECTED],disclaimerDescription= ,disclaimerText=One 
coupon per customer.,lastUpdate=Fri Sep 18 00:00:00 EDT 
1998]]],productImage=[],expirationDate=<null>,startDate=Tue Aug 31 00:00:00 EDT 
2004,endDate=T


ue Aug 31 00:00:00 EDT 2004,sequenceId=1,printLimit=0,displayExpiration=true]],webLink=[],productImage=[],printable=true,displayRanking=40000,[EMAIL PROTECTED],colorName=<null>,hexCode=<null>],[EMAIL PROTECTED],[EMAIL PROTECTED],couponSlugTypeName=<null>]], exception message is [Attempt to insert duplicate key row in object 'Coupon_Slugs' with unique index 'PK_COUPON_SLUGS'

]

        at 
com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1206)
        at 
com.newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java:1056)
        at 
com.newatlanta.sedebugger.Responder.processServletRequest(Responder.java:269)
        at com.newatlanta.sedebugger.Responder.run(Responder.java:92)

-----Original Message-----
From: Armin Waibel [mailto:[EMAIL PROTECTED]
Sent: Friday, February 18, 2005 10:39 AM
To: OJB Users List
Subject: Re: Persistence question


Hi Deb,

what OJB version do you use? Which api?
Could you post the whole stack trace.

regards,
Armin

Deborah Nunley wrote:


Sequence of events

I create the order with a product and persist it twice (as we gather information).
I delete the product from the order (within the application).
I add another product to the order.
I save the order again.


Everything looks good from the debugger but I get the following exception

SQL failure while insert object data for class com.valpak.productorder.couponslug.CouponSlug, PK of the given object is [ couponSlugId=665055], object was [EMAIL PROTECTED],sequenceId=1,address=[],[EMAIL PROTECTED],offerText=offer,additionalDisclaimerText=,couponSlugDisclaimer=[],productImage=[],expirationDate=<null>,startDate=Tue Aug 31 00:00:00 EDT 2004,endDate=Wed Aug 31 00:00:00 EDT 2005,sequenceId=1,printLimit=0,displayExpiration=true]],webLink=[],productImage=[],printable=true,displayRanking=39000,[EMAIL PROTECTED],colorName=<null>,hexCode=<null>],[EMAIL PROTECTED],[EMAIL PROTECTED],couponSlugTypeName=<null>]], exception message is [Attempt to insert duplicate key row in object 'Coupon_Slugs' with unique ind
e


x 'PK_COUPON_SLUGS'


Deb Nunley




---------------------------------------------------------------------
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]



------------------------------------------------------------------------

<class-descriptor
class="com.valpak.productorder.couponslug.CouponSlug"
table="Coupon_Slugs">
<field-descriptor
name="orderId"
column="Order_id"
jdbc-type="INTEGER"
access="anonymous">
</field-descriptor>
<field-descriptor
name="couponSlugId"
column="Coupon_Slug_id"
jdbc-type="INTEGER"
autoincrement="true" sequence-name="dp_AutoGen"
primarykey="true">
</field-descriptor>
<field-descriptor
name="couponSlugTypeId"
column="Coupon_Slug_Type_id"
jdbc-type="INTEGER"
access="anonymous">
</field-descriptor>
<reference-descriptor
name="couponSlugType"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
class-ref="com.valpak.productorder.couponslug.CouponSlugType">
<foreignkey field-ref="couponSlugTypeId"/>
</reference-descriptor> <field-descriptor
name="sequenceId"
column="Coupon_Slug_Sequence_id"
jdbc-type="INTEGER">
</field-descriptor>
<field-descriptor
name="displayRanking"
column="Display_Rank"
jdbc-type="INTEGER">
</field-descriptor>
<field-descriptor
name="printable"
column="Printable"
jdbc-type="BIT">
</field-descriptor>
<collection-descriptor
name="webLink"
element-class-ref="com.valpak.productorder.couponslug.CouponSlugWebLink"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="couponSlugId"/>
</collection-descriptor>
<collection-descriptor
name="productImage"
element-class-ref="com.valpak.product.option.ProductImage"
indirection-table="Coupon_Slug_Images"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<fk-pointing-to-this-class column="Coupon_Slug_id"/>
<fk-pointing-to-element-class column="Image_id"/>
</collection-descriptor> <field-descriptor
name="colorId"
column="Color_id"
jdbc-type="INTEGER"
access="anonymous"> </field-descriptor>
<reference-descriptor
name="background"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
class-ref="com.valpak.color.Color">
<foreignkey field-ref="colorId"/>
</reference-descriptor>
<collection-descriptor
name="address"
element-class-ref="com.valpak.productorder.couponslug.CouponSlugAddress"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="couponSlugId"/>
</collection-descriptor>
<collection-descriptor
name="offer"
element-class-ref="com.valpak.productorder.couponslug.CouponSlugOffer"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="couponSlugId"/>
</collection-descriptor>
<field-descriptor
name="zoneMapId"
column="Zone_Map_id"
access="anonymous"
jdbc-type="INTEGER">
</field-descriptor>
<reference-descriptor
name="zoneMap"
auto-retrieve="true"
auto-update="true"
auto-delete="false"
class-ref="com.valpak.targetedcontent.ZoneMap">
<foreignkey field-ref="zoneMapId"/>
</reference-descriptor> </class-descriptor>


<class-descriptor
class="com.valpak.order.Order"
table="Orders">


<field-descriptor
name="orderId"
column="Order_id"
jdbc-type="INTEGER"
autoincrement="true" sequence-name="dp_AutoGen"
primarykey="true">
</field-descriptor> <field-descriptor
name="businessName"
column="Business_Name"
jdbc-type="VARCHAR">
</field-descriptor> <field-descriptor
name="dataPartnerId"
column="Data_Partner_id"
jdbc-type="INTEGER"
access="anonymous">
</field-descriptor>
<reference-descriptor
name="dataPartner"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
class-ref="com.valpak.partner.DataPartner">
<foreignkey field-ref="dataPartnerId"/>
</reference-descriptor>
<field-descriptor
name="orderStatusId"
column="Order_Status_id"
jdbc-type="VARCHAR"
access="anonymous">
</field-descriptor>
<reference-descriptor
name="status"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
class-ref="com.valpak.order.OrderStatus">
<foreignkey field-ref="orderStatusId"/>
</reference-descriptor>
<field-descriptor
name="tcDescriptorId"
column="Targeted_Content_Descriptor_id"
jdbc-type="INTEGER"
access="anonymous">
</field-descriptor>
<reference-descriptor
name="tcDescriptor"
auto-retrieve="true"
auto-update="true"
auto-delete="true"
class-ref="com.valpak.targetedcontent.TargetedContentDescriptor">
<foreignkey field-ref="tcDescriptorId"/>
</reference-descriptor> <field-descriptor
name="naicsId"
column="NAIC_id"
jdbc-type="INTEGER"
access="anonymous">
</field-descriptor>
<reference-descriptor
name="naics"
auto-retrieve="true"
auto-update="false"
auto-delete="false"
class-ref="com.valpak.naics.VPColNaics">
<foreignkey field-ref="naicsId"/>
</reference-descriptor>
<collection-descriptor
name="couponSlug"
element-class-ref="com.valpak.productorder.couponslug.CouponSlug"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="orderId"/>
</collection-descriptor>
<collection-descriptor
name="targetedLink"
element-class-ref="com.valpak.productorder.targetedlink.TargetedLink"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="orderId"/>
</collection-descriptor> <collection-descriptor
name="transactionHistory"
element-class-ref="com.valpak.order.OrderTransactionHistory"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="orderId"/>
</collection-descriptor>
<collection-descriptor
name="salesStaff"
element-class-ref="com.valpak.order.SalesStaffOrder"
auto-retrieve="true"
auto-update="true"
auto-delete="true">
<inverse-foreignkey field-ref="orderId"/>
</collection-descriptor> </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]



Reply via email to