Re: MS SQL Server and Deferred Constraints
Re: MS SQL Server and Deferred Constraints
- Subject: Re: MS SQL Server and Deferred Constraints
- From: David Avendasora <email@hidden>
- Date: Fri, 29 Jun 2007 15:08:03 -0500
Okay, I've installed Wonder's Extensions framework and changed my
Application class to call Chuck's code. But it's still not working.
I'm still getting the COLUMN FOREIGN KEY constraint error. I'm not
sure if I'm not calling the new Wonder functionality properly, or if
It has to do with the fact that the Entity I'm trying to copy is in a
framework as opposed to the client.
Let me give some more detail on my project.
I have a core framework for my project (bmcore.framework) that has
the EOModel in it and all my core business-logic classes in it (it
has no Application class as it is a framework). I have two different
front-ends for this framework: A web-UI for regular users and a Java
Client (D2JC) Admin UI just for me (and one other Admin person). Both
UI's need the ability to Copy a relatively complicated EO that has
multiple relationships (toOne, toMany, some own the destination, some
don't). So far I have added the chucks code to the Application class
in my Java Client.
I am using the EOEntityCopier class from Practical WebObjects to do
the work. Here's the method, it resides in the Entity I'm copying,
which is in the bmcore.framwork.
public void cloneBillOfMaterial(EOEditingContext ec) {
BillOfMaterial clonedBillOfMaterial = (BillOfMaterial)
EOEntityCopier.deepCopy(ec,this);
clonedBillOfMaterial.setRoutingDescription
(clonedBillOfMaterial.routingDescription() + " CLONE");
ec.saveChanges();
}
When I call this method from the Java Client, I get the following
COLUMN FOREIGN KEY constraint error:
Exception in thread "AWT-EventQueue-0"
java.lang.IllegalStateException: Server exception: EvaluateExpression
failed: <com.webobjects.jdbcadaptor.MicrosoftPlugIn
$MicrosoftExpression: "INSERT INTO dbo.Routing_Step(Routing_ID,
Routing_Step_Sequence, Instructions, Routing_Step_Name, Tool_ID,
Routing_Step_ID) VALUES (?, ?, ?, ?, ?, ?)" withBindings: 1:1822
(routingId), 2:4(routingStepSequence), 3:"Stack required
numbe...machine and labeler."(instructions),
4:"Packaging"(routingStepName), 5:73(toolId), 6:7528(routingStepId)>:
Next exception:SQL State:23000 -- error code: 547 -- msg:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]INSERT
statement conflicted with COLUMN FOREIGN KEY constraint
'FK_Routing_Step_Routing'. The conflict occurred in database
'bakeryManagement', table 'Routing', column 'Routing_ID'.
Next exception:SQL State:HY000 -- error code: 3621 -- msg:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]The statement
has been terminated.
Next exception:SQL Warning: -- error code: 0 -- msg: [Microsoft]
[SQLServer 2000 Driver for JDBC]Database changed to bakeryManagement
Next exception:SQL Warning:01000 -- error code: 5701 -- msg:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed
database context to 'bakeryManagement'.
Next exception:SQL Warning: -- error code: 0 -- msg: [Microsoft]
[SQLServer 2000 Driver for JDBC]Language changed to us_english
Next exception:SQL Warning:01000 -- error code: 5703 -- msg:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed
language setting to us_english.
at
com.webobjects.eodistribution.client.EODistributedObjectStore._checkRetu
rnValuesForExceptions(EODistributedObjectStore.java:569)
at
com.webobjects.eodistribution.client.EODistributedObjectStore._send
(EODistributedObjectStore.java:597)
at
com.webobjects.eodistribution.client.EODistributedObjectStore.invokeRemo
teMethod(EODistributedObjectStore.java:968)
at
com.webobjects.eodistribution.client.EODistributedObjectStore.invokeRemo
teMethod(EODistributedObjectStore.java:923)
at com.webobjects.eocontrol.EOEditingContext.invokeRemoteMethod
(EOEditingContext.java:5126)
at com.webobjects.eocontrol.EOCustomObject.invokeRemoteMethod
(EOCustomObject.java:832)
at
com.bestmaid.bakeryManagement.client.routing.BillOfMaterial.cloneBillOfM
aterial(BillOfMaterial.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSSelector.invoke(NSSelector.java:354)
at com.webobjects.foundation.NSSelector._safeInvokeSelector
(NSSelector.java:108)
at com.webobjects.eointerface.EOActionAssociation.invokeAction
(EOActionAssociation.java:148)
at
com.webobjects.eointerface.swing.EOSwingButtonPlugin.actionPerformed
(EOSwingButtonPlugin.java:88)
at javax.swing.AbstractButton.fireActionPerformed
(AbstractButton.java:1882)
at javax.swing.AbstractButton$Handler.actionPerformed
(AbstractButton.java:2202)
at javax.swing.DefaultButtonModel.fireActionPerformed
(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:
258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased
(BasicButtonListener.java:234)
at java.awt.Component.processMouseEvent(Component.java:5554)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5319)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4021)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3869)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:
4256)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:
3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3869)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:
176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
On Jun 27, 2007, at 2:51 PM, Chuck Hill wrote:
Hi David,
I am just cleaning up code to handle this and also ordering the
DROP TABLE statements for MSSQL. It should be in Wonder in a few
hours.
MSSQL suxOr.
Chuck
On Jun 27, 2007, at 12:43 PM, David Avendasora wrote:
I know this issue has been discussed before, or at least eluded to
in posts, but I'm having problems with EOF inserting records into
related tables before it inserts them into the primary table (I
end up with Foreign key constraint SQL errors).
I'm using MS SQL Server (I know, but it is a requirement for the
application) and I need to have some way of making sure when
EOEditingContext.saveChanges() executes, it saves the records
bound for the primary table first. Here's my structure:
Routing<->>RoutingStep<->>RoutingComponent
Records for three are being instantiated in one EOEditingContext,
but when I call saveChanges() on it, sometimes (but not always) it
errors because it tries to insert RoutingComponent prior to
RoutingStep or RoutingStep prior to Routing into the database.
the end of the transaction. What is the most effective way to work
around this? I'm sure it has been addressed by people before and
if I'm just not finding it (I googled it). If it's out there, just
paste a link, if not, can someone share a code sample of how they
deal with it?
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden