Dear all,
I have a table with 2 primary keys as follows: .... <field type="id-ne" name="asset_itemid"></field> <field type="id-ne" name="depid"/> <field type="id" name="account_no"/> <field type="currency-amount" name="value_before_cal"/> <field type="currency-amount" name="depre_value"/> <field type="currency-amount" name="value_after_cal"/> <field type="date" name="calculate_date"/> <field type="short-varchar" name="table_name"/> <prim-key field="asset_itemid"/> <prim-key field="calculate_date"/> ..... Normally, if the table has 1 primary key, I will do like this: GenericValue accObj = delegator.makeValue("DepreciationTrans", UtilMisc.toMap( "asset_itemid", asset_itemid)); //create generic value from id but now I have 2 primary key, so I do like this: GenericValue accObj = delegator.makeValue("DepreciationTrans", UtilMisc.toMap( "asset_itemid", asset_itemid),UtilMisc.toMap("calculate_date", calculate_date)); //create generic value from id Then it caused error as follows: 2008-04-20 04:06:31,968 (http-0.0.0.0-8080-Processor3) [ RequestHandler.java:316:ERROR] Request doCreateDepreTable caused an error with the following message: Error calling event: org.ofbiz.webapp.event.EventHandlerException: Service invocation error (org.ofbiz.base.util.UtilMisc$SimpleMap) How can I write code for table with 2 primary key to create GenericValue Nattanicha |
Hi Nattanicha
You can do either of the following: GenericValue accObj = delegator.makeValue("DepreciationTrans", UtilMisc.toMap("asset_itemid", asset_itemid, "calculate_date", calculate_date)); or GenericValue accObj = delegator.makeValue("DepreciationTrans", "asset_itemid", asset_itemid, "calculate_date", calculate_date); Regards Scott On 20/04/2008, Nattanicha Rittammanart <[hidden email]> wrote: > > Dear all, > I have a table with 2 primary keys as follows: > > .... > <field type="id-ne" name="asset_itemid"></field> > <field type="id-ne" name="depid"/> > <field type="id" name="account_no"/> > <field type="currency-amount" name="value_before_cal"/> > <field type="currency-amount" name="depre_value"/> > <field type="currency-amount" name="value_after_cal"/> > <field type="date" name="calculate_date"/> > <field type="short-varchar" name="table_name"/> > <prim-key field="asset_itemid"/> > <prim-key field="calculate_date"/> > ..... > Normally, if the table has 1 primary key, I will do like this: > > GenericValue accObj = delegator.makeValue("DepreciationTrans", > UtilMisc.toMap( > "asset_itemid", asset_itemid)); //create generic value > from id > > but now I have 2 primary key, so I do like this: > > GenericValue accObj = delegator.makeValue("DepreciationTrans", > UtilMisc.toMap( > "asset_itemid", > asset_itemid),UtilMisc.toMap("calculate_date", calculate_date)); //create > generic value from id > > Then it caused error as follows: > > 2008-04-20 04:06:31,968 (http-0.0.0.0-8080-Processor3) [ > RequestHandler.java:316:ERROR] Request doCreateDepreTable caused an error > with the following message: Error calling event: > org.ofbiz.webapp.event.EventHandlerException: Service invocation error > (org.ofbiz.base.util.UtilMisc$SimpleMap) > > How can I write code for table with 2 primary key to create GenericValue > > Nattanicha > |
Thank you very much, Scoot
Scott Gray wrote: > Hi Nattanicha > > You can do either of the following: > GenericValue accObj = delegator.makeValue("DepreciationTrans", > UtilMisc.toMap("asset_itemid", asset_itemid, "calculate_date", > calculate_date)); > or > GenericValue accObj = delegator.makeValue("DepreciationTrans", > "asset_itemid", asset_itemid, "calculate_date", calculate_date); > > Regards > Scott > > On 20/04/2008, Nattanicha Rittammanart <[hidden email]> wrote: > >> Dear all, >> I have a table with 2 primary keys as follows: >> >> .... >> <field type="id-ne" name="asset_itemid"></field> >> <field type="id-ne" name="depid"/> >> <field type="id" name="account_no"/> >> <field type="currency-amount" name="value_before_cal"/> >> <field type="currency-amount" name="depre_value"/> >> <field type="currency-amount" name="value_after_cal"/> >> <field type="date" name="calculate_date"/> >> <field type="short-varchar" name="table_name"/> >> <prim-key field="asset_itemid"/> >> <prim-key field="calculate_date"/> >> ..... >> Normally, if the table has 1 primary key, I will do like this: >> >> GenericValue accObj = delegator.makeValue("DepreciationTrans", >> UtilMisc.toMap( >> "asset_itemid", asset_itemid)); //create generic value >> from id >> >> but now I have 2 primary key, so I do like this: >> >> GenericValue accObj = delegator.makeValue("DepreciationTrans", >> UtilMisc.toMap( >> "asset_itemid", >> asset_itemid),UtilMisc.toMap("calculate_date", calculate_date)); //create >> generic value from id >> >> Then it caused error as follows: >> >> 2008-04-20 04:06:31,968 (http-0.0.0.0-8080-Processor3) [ >> RequestHandler.java:316:ERROR] Request doCreateDepreTable caused an error >> with the following message: Error calling event: >> org.ofbiz.webapp.event.EventHandlerException: Service invocation error >> (org.ofbiz.base.util.UtilMisc$SimpleMap) >> >> How can I write code for table with 2 primary key to create GenericValue >> >> Nattanicha >> >> > > > > __________ NOD32 3041 (20080419) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > > |
Free forum by Nabble | Edit this page |