# using objects instead of hashmap to set properties

**URL:** <https://forum.servoy.com/t/using-objects-instead-of-hashmap-to-set-properties/13075>\
**Category:** Classic Servoy\
**Created:** [October 20, 2010, 12:16pm UTC](https://forum.servoy.com/t/using-objects-instead-of-hashmap-to-set-properties/13075 "2010-10-20T12:16:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [October 20, 2010, 12:16pm UTC](https://forum.servoy.com/t/using-objects-instead-of-hashmap-to-set-properties/13075/1 "2010-10-20T12:16:01Z")

</div>

Hi,

for setting jasper reports we were using hashmaps, to send the parameters to the report, like this:

```auto
var $ParametersMap = new java.util.HashMap(); //object
$ParametersMap.put('invoiceid', invoicesid);

```

in the new version of our solution we switched to using objects like this:

```auto
var vParameters = new Object(); //object
vParameters.invoiceid = invoicesid

```

Now sometimes, we get this error in the debug or realclient:

```auto
Incompatible java.lang.Long value assigned to parameter invoiceid in the invoice1 dataset.
Wrapped java.lang.Exception: Incompatible java.lang.Long value assigned to parameter invoiceid in the invoice1 dataset. (D:\Servoy_Workspaces\servoy_workspace5\DirectManager\forms\invoices_print_menu.js#135)

```

the parameter: invoiceid in jasper is of type: java.lang.Integer. Should I change that to java.lang.Long?

The weird thing is that when we are using using hashmaps, this error never occurs.  
Anyone knows, what is going on here?

---

<div class="post-metadata">

**Author:** ![Thomas\_Parry](https://avatars.discourse-cdn.com/v4/letter/t/b38774/32.png) [@Thomas\_Parry](https://forum.servoy.com/u/Thomas_Parry)\
**Post date:** [October 20, 2010, 1:14pm UTC](https://forum.servoy.com/t/using-objects-instead-of-hashmap-to-set-properties/13075/2 "2010-10-20T13:14:10Z")

</div>

you might try

```auto
var vParameters = new Object(); //object
vParameters.invoiceid = new java.lang.Integer(invoicesid)

```

In order to force the type to Integer  
Although the jasper plugin might not be able to differentiate due to the javascript assignment.

---

<div class="post-metadata">

**Author:** ![Harjo](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/harjo/32/4873_2.png) [@Harjo](https://forum.servoy.com/u/Harjo)\
**Post date:** [October 20, 2010, 1:20pm UTC](https://forum.servoy.com/t/using-objects-instead-of-hashmap-to-set-properties/13075/3 "2010-10-20T13:20:26Z")

</div>

oke i tried your suggestion, but now it says:

```auto
Incompatible java.util.HashMap value assigned to parameter invoiceid in the invoice1 dataset.
Wrapped java.lang.Exception: Incompatible java.util.HashMap value assigned to parameter invoiceid in the invoice1 dataset. (D:\Servoy_Workspaces\servoy_workspace5\DirectManager\forms\invoices_print_menu.js#136)

```

I did’nt switch back to hashmaps!! ![:shock:]( "Shocked")

the problem is with new created invoices (in this case invoiceid = 603)  
when I restart de debug client and fire the same record to jasper report, no error and everything is fine!!
