Looked in glance... It is strange... should work.
on
http://www.hibernate.org/hib_docs/reference/en/html/collections.html#collections-onetomany
wrote
Quote:
Very Important Note: If the <key> column of a <one-to-many> association is declared NOT NULL, Hibernate may cause constraint violations when it creates or updates the association. To prevent this problem, you must use a bidirectional association with the many valued end (the set or bag) marked as inverse="true". See the discussion of bidirectional associations later in this chapter
As I see you use bidirectional association, and everything should be fine, you also bind your children to the parent in
Code:
public void addChild(OrderItem child){
child.setOrder_id(this);
children.add(child);
}
But what is wrong? ...
For test try to remove NOT NULL constraint for CoffeeOrderItem.order_id,
let it be:
Quote:
create table CoffeeOrderItem (
id int not null, -- pk
order_id int, -- NOT NULL removed
quantity int, --
primary key (id)
) type=InnoDB;
And at first try without index for CoffeeOrderItem.order_id.
--
Leonid