Question

Is there any way to serialize an ORMLite prepared query and then deserialize to restore it to the original form?

In Android passing parameters to activities or fragments must be done in serialized form. Now it seems impossible to pass prepared queries as arguments in a Bundle.

Serializing them is not a problem because there is PreparedStmt<T>.getStatement() but I have not found any way to reverse the process.

There is always the solution of putting the query in a map with a String key, passing the key as an argument and then retrieving the query using that key, but I am searching for a simpler solution.

Was it helpful?

Solution

Is there any way to serialize an ORMLite prepared query and then deserialize to restore it to the original form?

Right now the answer is no and I don't think there is any way for the code to be changed to support it. A prepared query contains points to the DAO, to the internal connection source classes, etc. so it can perform its duties. There is no easy way to serialize all that information at this time.

Serializing them is not a problem because there is PreparedStmt.getStatement() but I have not found any way to reverse the process.

By reverse the process you mean generate a PreparedStmt from the query string? You should be able to do:

 GenericRawResults<T> results = dao.QueryRaw(queryString, dao.getRawRowMapper());
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top