Can't pickle <java class 'java.lang.Integer'> in python

1.4k views Asked by At

I'm fetching data from a db with the use of jaydebeapi pkg. I want to serialize the data (it's in list of tuples format) using pickle.

The data may contain different java class types. For a certain data type (<java class 'java.lang.Integer'>) I get the following error message:

PicklingError: Can't pickle <java class 'java.lang.Integer'>: it's not found as java.lang.java.lang.Integer

Is there any way to fix this? Or is there any known workaround?

Thanks a lot!

1

There are 1 answers

0
Munick On BEST ANSWER

You should use the JPype Pickle Module instead of pickle.

from jpype.pickle import JPickler

From the docs:

Mixed pickle files containing both Java and Python objects are allowed.