Simple Order -> OrderLine configuration fails

5 views
Skip to first unread message

Holtkamp

unread,
Aug 2, 2010, 6:06:15 PM8/2/10
to Outlet ORM
I have been breaking my head on a "problem" that should not be that
complex. Maybe it is a shortcoming of Outlet, but I think I am missing
something.

Context: the simple Order / OrderLine situation

One Order
- can have multiple orderLines (one-to-many)
- is taken care of by one ServiceProvider, who can handle multiple
orders (many-to-one)
- is placed by a ServiceConsumer, who can place multiple orders (many-
to-one)

One OrderLine
- is related to one specific Order, but multiple OrderLines can exist
in a single Order (many-to-one)
- is related to one CatalogItem (or product), but a CatalogItem can
occur in multiple OrderLines (many-to-one)

Approach (pseudo) - addProduct():
- $order = new Order();
- $orderLine[1..N] = new OrderLine();
- $order->addOrderLine($orderline1);
- $order->addOrderLine($orderline2);
- $order->addOrderLine($orderlineN);

$dao = new Dao_Outlet_Order()
$dao->save($order);

However, this seems to result in a lifelock:
- Order is saved, OrderLines are detected
- OrderLines need to be saved, primary key of the Order is set
(orderId) based on the acquired auto incremented ID
- OrderLine is saved, but this detects that the Order needs to be
saved (in the OutletMapper::isNew() method)

I have tried Outlet-RC1 and the latest trunk versions, but both finish
with a lot of Orders added to the database, no Orderlines added and an
out of memory exception.

What am I missing here? I searched to group and documentation, this
post seems to relate but it is quite old:
http://groups.google.com/group/outlet-orm/browse_thread/thread/7c32ebeb0af22779/e18f28fe57ed7c06?lnk=gst&q=orderline#e18f28fe57ed7c06


For the sake of simplicity, I will present only the relevant part of
my configuration:
Note that the table of the Orders is called "orders", while I tend to
use the object name: "order", but this interferes with the SQL
standard, might this be the problem? As in some queries still {Order}
will be used?
array(2) {
["connection"] => array(4) {
["dialect"] => string(5) "mysql"
...
}
["classes"] => array(2) {
["Order"] => array(3) {
["table"] => string(6) "orders"
["props"] => array(3) {
["orderId"] => array(3) {
[0] => string(7) "orderId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(true)
["autoIncrement"] => bool(true)
}
}
}
["associations"] => array(1) {
[0] => array(3) {
[0] => string(11) "one-to-many"
[1] => string(10) "Order_Line"
[2] => array(3) {
["key"] => string(7) "orderId"
["name"] => string(9) "OrderLine"
["plural"] => NULL
}
}
}
}
["Order_Line"] => array(3) {
["table"] => string(9) "orderline"
["props"] => array(4) {
["orderLineId"] => array(3) {
[0] => string(11) "orderLineId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(true)
["autoIncrement"] => bool(true)
}
}
["orderId"] => array(3) {
[0] => string(7) "orderId"
[1] => string(3) "int"
[2] => array(2) {
["pk"] => bool(false)
["autoIncrement"] => bool(false)
}
}
}
["associations"] => array(1) {
[0] => array(3) {
[0] => string(11) "many-to-one"
[1] => string(5) "Order"
[2] => array(3) {
["key"] => string(7) "orderId"
["name"] => NULL
["optional"] => NULL
}
}
}
}
}
}

Holtkamp

unread,
Aug 2, 2010, 6:20:03 PM8/2/10
to Outlet ORM
Well,

I can reply to myself. My notice about the objectname 'Order' and the
restricted keyword in SQL triggered me for a final and desparate
attempt to use a different name for the Order property of the
OrderLine object:

["Order_Line"] => array(3) {
["table"] => string(9) "orderline"
... properties nothing changed here ....
["associations"] => array(1) {
[0] => array(3) {
[0] => string(11) "many-to-one"
[1] => string(5) "Order"
[2] => array(3) {
["key"] => string(7) "orderId"
["name"] => string(11) "OrderObject"
["optional"] => NULL
}
}
}
}

Added the getOrderObject() and setOrderObject() and now it seems to
work...

Should have thought about it before...

Cheers!
> post seems to relate but it is quite old:http://groups.google.com/group/outlet-orm/browse_thread/thread/7c32eb...

Holtkamp

unread,
Aug 2, 2010, 7:01:17 PM8/2/10
to Outlet ORM
Unfortunately this was not the final solution, after reverting my
changed libraries to the original state, the 'lifelocking' behaviour
returned and I am not able to reproduce a hack...

Suggestions are welcome!

Cheers!

Holtkamp

unread,
Aug 3, 2010, 2:48:38 AM8/3/10
to Outlet ORM
It turned out I explicitely called

$orderLine->setOrder($this)
in the Order.addOrderLine() method. Which is a part Outlet should take
care of.

Now it works, with the normal name 'Order' and with both 1.0-RC1 and
trunk versions.

Cheers!
Reply all
Reply to author
Forward
0 new messages