on 05-14-2010 10:01 PM
Hi
I am trying to insert a new item by selecting the header record
it is ending up with a Illegal state exception Caused by: java.sql.SQLException: Duplicate key: XXXXXX
experts could you please check this thanks !!!!
below is the code i am using to insert the item
ZkumarHeader header = (ZkumarHeader)wdContext.nodezkumar_srv().nodeget_header_asset().nodeget_header_assetOutput().getCurrentElement().model();
ZkumarItem item;
if (header.getItems().size() > 0)
{
item = (ZkumarItem)header.getItems().toArray()[0];
}
else
{
item = header.createNewItems();
}
header.addToItems(item);
wdContext.nodezkumar_srv().nodeget_item_asset().nodeget_item_assetOutput().bind(Collections.singleton(item));
wdContext.nodezkumar_srv().nodeget_item_asset().nodeget_item_assetOutput().setLeadSelection(0);
OcaRoot.getInstance().commit();
hi Anesht,
I think the problem is in the if else block
if (header.getItems().size() > 0)
{
item = (ZkumarItem)header.getItems().toArray()[0];
}
header.addToItems(item);
If an item already exists then you are trying to add the same item again. This will give duplicate item key.
the code header.addToItems(item); should be present in the else block.
Hope this resolves your problem.
Regards,
Priya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.