Page 1 of 1

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Fri Jun 02, 2017 9:58 am
by johnlong
Thank you. Could you please answer this question as well: how exactly TimerHandle could be persisted? And where would you persist it to?

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Fri Jun 02, 2017 10:32 am
by admin
As the option says, it is serializable. So a TimerHandle can be serialized and saved anywhere such as a file or even in a database just like any other serializable class. This is OCPJP stuff :)
Paul.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Fri Jun 02, 2017 10:14 pm
by johnlong
Is there requirement for object to be serializable in order to be saved into file or database?
As I understand we usually serialize if we send object over the wire so it can be deserialized at the other end.
But specifications state that TimerHandle should not be passed remotely.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sat Jun 03, 2017 12:00 am
by admin
It really depends on what you mean by successfully saving an object. The whole point is that once you unserialize the serialized data back into an object, you should be able to call methods on it and the methods should actually work just as the original object. Serializable is one way that achieves this. Serialization is not only for remote access. You can use serialization in the same JVM also.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sat Jun 03, 2017 7:50 am
by johnlong
For example, let's say I make TimerHandle an Entity, and persist it using ORM tools, would I need serialization in this case? Or you mean that by serializing I will make my life easier (easier object back to life process?)

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sat Jun 03, 2017 9:51 pm
by admin
Ultimately an object is made up of its fields. So if you are able to recreate an object with the same values for all its fields, it doesn't matter whether you use serialization or orm or anything else. serialization may make it easier in some situations.
Having said that you can't make TimerHandle an entity because this class is not your class. It is a framework class and you can't change its code. Can you?

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sat Jun 10, 2017 8:53 am
by johnlong
It is not necessary to change class code, you can make framework class entity via xml mapping.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sat Jun 10, 2017 11:53 pm
by admin
Sounds good. As I said before, if you are able to reproduce all the fields of an object with the same values, it does't matter whether you did it using serialization or something else. You can try saving TimerHandle using an orm and see if it works after recreation.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sun Jun 11, 2017 9:15 am
by johnlong
I will try. My point is that object does not have to be serializable in order to be persisted. Is my understanding wrong in your opinion?

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Sun Jun 11, 2017 9:43 pm
by admin
That is correct. But if an object is Serializable, it can be persisted.

Re: About Question enthuware.oce-ejbd.v6.2.431 :

Posted: Mon Jun 12, 2017 9:10 am
by johnlong
Still did not get why there is a requirement to get it Serialized, but let's leave it, I will try to investigate this topic some other time. Thank you very much for your explanations.