Author |
Message
|
mqjeff |
Posted: Wed Jun 26, 2013 5:38 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The question is, what does the base MbGlobalCache functionality do when presented with a serializable object.
Does it automatically assume that it supports a specific toString or toArray or etc. function, or does it merely throw an error that it's not a String.
Given that IBM doesn't document this, it's not unreasonable to expect that the only functions that are supported are those that are actually documented.
The fact that one can make the behavior one wants available with some advanced Java knowledge (yes, alas, this is *advanced* java knowledge) is less germane than a texes legislature's opinion of the time of day. |
|
Back to top |
|
 |
iShakir |
Posted: Wed Jun 26, 2013 6:09 am Post subject: |
|
|
Apprentice
Joined: 07 Mar 2013 Posts: 47
|
There has been a mistake in communication here.
Of course I was not implying that the data couldn't be represented by something that could then be put to the cache (and my apologies if that's how it came across.) It's more that the actual act of:
Code: |
MbGlobalMap.put(key, Object object)
MbGlobalMap.get(key) |
or even:
Code: |
MbGlobalMap.put(key, Serializable object)
MbGlobalMap.get(key) |
cannot be assumed to work, as per the documentation.
Last edited by iShakir on Wed Jun 26, 2013 6:11 am; edited 1 time in total |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Jun 26, 2013 6:10 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
iShakir wrote: |
There has been a mistake in communication here.
Of course I was not implying that the data couldn't be represented by something that could then be put to the cache (and my apologies if that's how it came across.) It's more that the actual act of:
Code: |
MbGlobalMap.put(key, Object object) |
or even:
Code: |
MbGlobalMap.put(key, Serializable object) |
cannot be assumed to work, as per the documentation. |
I'm in full agreement. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Wed Jun 26, 2013 7:29 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mqjeff wrote: |
iShakir wrote: |
There has been a mistake in communication here.
Of course I was not implying that the data couldn't be represented by something that could then be put to the cache (and my apologies if that's how it came across.) It's more that the actual act of:
Code: |
MbGlobalMap.put(key, Object object) |
or even:
Code: |
MbGlobalMap.put(key, Serializable object) |
cannot be assumed to work, as per the documentation. |
I'm in full agreement. |
I also.
http://www.tutorialspoint.com/java/java_serialization.htm
Code: |
AllergyCode ac = new AllergyCode();
ac.setMyName( "abc" );
MbGlobalMap.put(key, ac);
|
Under no circumstance would you ever define an object in-line to a call to MbGlobalMap.put.
http://en.wikipedia.org/wiki/Serialization
http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html
Quote: |
Serializability of a class is enabled by the class implementing the java.io.Serializable interface. Classes that do not implement this interface will not have any of their state serialized or deserialized. All subtypes of a serializable class are themselves serializable. The serialization interface has no methods or fields and serves only to identify the semantics of being serializable.
To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype's public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class's state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime.
|
_________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
touchofcrypticthunder |
Posted: Thu Jun 27, 2013 7:42 am Post subject: |
|
|
Apprentice
Joined: 08 Jul 2009 Posts: 30
|
Finally I implemented AllergyCode caching solution using array of String datatype which works fine. I could manage to use string of array as value to GlobalCache for this usecase as there were 2 or 3 fields which was required for cross ref.
But when the usecase involves more number of fields to be put into cache, this solution may not be feasible which requires Java object which I tried to implement in the beginning.
Infact I implemented the java object as Serializable but still it did not work with GlobalCache. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jun 27, 2013 7:44 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You can use any Serializable object you want.
You just have to explicitly serialize it into a string yourself before you stick it in the global map, and then explicitly unserialize it when you retrieve it from the globla map. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jun 27, 2013 10:03 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
mqjeff wrote: |
You can use any Serializable object you want.
You just have to explicitly serialize it into a string yourself before you stick it in the global map, and then explicitly unserialize it when you retrieve it from the globla map. |
As is specified in the English language translation of the Java reference above:
Quote: |
To allow subtypes of non-serializable classes to be serialized, the subtype may assume responsibility for saving and restoring the state of the supertype's public, protected, and (if accessible) package fields. The subtype may assume this responsibility only if the class it extends has an accessible no-arg constructor to initialize the class's state. It is an error to declare a class Serializable if this is not the case. The error will be detected at runtime. |
If English is difficult to understand for you, specify what is your first language and I will hop on the blue line to get a good translation.
http://www.bluelines.eu/ _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
jhart |
Posted: Fri Jul 19, 2013 7:43 am Post subject: |
|
|
Novice
Joined: 12 Dec 2012 Posts: 19 Location: IBM Hursley, UK
|
|
Back to top |
|
 |
|