miro_con@yahoo.com wrote:
I am using opensessionview
I have Items (parent )and bids (child)
In my application I first create items and save them .
next i create bids add them to the item and save item (because I am using opensessionview no flush is called after adding bids , so when I see the id with the bid it is null ) is this normal or am I doing anything wrong ?
and finally I have a table bid_users
which just has a user_id and bid_id,
the pk for this table is composite key (bid_id, user_id)
I get the userId from session and bid_id from ((Bid)items.getBids().iterator().next()).getId() , but here the bid_id is null and saving the instance bid_users throws sql exception because bid_id is null and bid_id has not nullable constraint ,Please help me resolve this
in simple terms
parent.getChildren().add(child);
child.setParent(parent);
getSession().save(parent)
I cannot call flush here
and I want the PK for the child but it is null , can I ask hibernate to generate pk with save ?