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

Moderator: admin

Post Reply
johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Fri Jun 02, 2017 9:58 am

Thank you. Could you please answer this question as well: how exactly TimerHandle could be persisted? And where would you persist it to?

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Fri Jun 02, 2017 10:32 am

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.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Fri Jun 02, 2017 10:14 pm

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.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 03, 2017 12:00 am

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.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sat Jun 03, 2017 7:50 am

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?)

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 03, 2017 9:51 pm

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?
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sat Jun 10, 2017 8:53 am

It is not necessary to change class code, you can make framework class entity via xml mapping.

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sat Jun 10, 2017 11:53 pm

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.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Sun Jun 11, 2017 9:15 am

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?

admin
Site Admin
Posts: 8239
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin » Sun Jun 11, 2017 9:43 pm

That is correct. But if an object is Serializable, it can be persisted.
If you like our products and services, please help us by posting your review here.

johnlong
Posts: 185
Joined: Mon Jun 20, 2016 5:06 pm
Contact:

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

Post by johnlong » Mon Jun 12, 2017 9:10 am

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests