on ‎2021 Aug 20 9:12 AM
Hi all,
I have created on collections attribute in order itemtype, I'm fetching data from cartModel.getEntries() and storing it into String List, and adding this list into the ordermodel and calling getModelService().save(orderModel). After placing order data is not getting stored, I'm not getting any error.
item xml and java code is as below, can anyone suggest, what is wrong
<collectiontype code="BatchCollection" elementtype="java.lang.String" autocreate="true" generate="false"/>
<itemtype code="Order" autocreate="false" generate="true">
<attributes>
<attribute qualifier="batchNumber" type="BatchCollection">
<persistence type="property" />
<description>Batch Number</description>
</attribute>
<attributes>
</itemtype>
Collection<String> batchList = new ArrayList<String>();
for(AbstractOrderEntryModel batch:cartModel.getEntries()){
batchList.add(batch.getBatchNumber());}
orderModel.setBatchNumber(batchList);
getModelService().save(orderModel);
Request clarification before answering.
Hello,
Only missing I see is the type="list" parameter.
try it out, for setting value you need to use one of the collection implementations like List.
Thanks! let me know if worked.
<collectiontype code="BatchCollection" elementtype="java.lang.String" autocreate="true" generate="false" type="list"/>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.