About Question enthuware.oce-ejbd.v6.2.431 :
Moderator: admin
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
Thank you. Could you please answer this question as well: how exactly TimerHandle could be persisted? And where would you persist it to?
Online
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
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.
Online
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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?)
Online
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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?
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.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
It is not necessary to change class code, you can make framework class entity via xml mapping.
Online
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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?
Online
-
- Site Admin
- Posts: 10102
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
-
- Posts: 197
- Joined: Mon Jun 20, 2016 5:06 pm
- Contact:
Re: About Question enthuware.oce-ejbd.v6.2.431 :
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.
Who is online
Users browsing this forum: No registered users and 1 guest