Re: Entity Modeler and java.io.Serialization
Re: Entity Modeler and java.io.Serialization
- Subject: Re: Entity Modeler and java.io.Serialization
- From: Chuck Hill <email@hidden>
- Date: Thu, 11 Aug 2011 09:23:16 -0700
On 2011-08-11, at 8:42 AM, John Huss wrote:
> If you use the ERAttributeExtension framework or whatever it's called I think could do it - this is what the joda time prototypes use. It fixes the features that were supposed to be in 5.4
ERAttributeExtension "just" makes it easier (or possible) to use the Factory Method: / Conversion Method: stuff in EOF:
The EOAttribute class allows you to model an attribute for a java object. In order to do this, the java class must implement a custom conversion method to write the value into the database and a value factory method to read the object back out. In some cases, you may want to use a java class as an attribute which does not implement a method appropriate for these operations. In some cases, the java class may even befinal making it impossible to model the class as a custom attribute.
The ERAttributeExtension framework is designed to solve this problem. It does so by reimplementing EOAttribute. The reimplemented EOAttribute fixes the broken implementation of WO 5.4.3's adaptorValueConversionClassName characteristic and adds a new valueFactoryClassName characteristic to EOAttribute. Therefore, any prototype attribute which uses one of these two attribute characteristics in ERPrototypes requires the inclusion of this framework to work properly.
> But I'm not sure why you would want to store it in a binary format; if you just need to convert a stored string to an InetAddress there probably an easier way, like modifying your EO templates.
+1
If you store it in a binary format, how you are going to query on it? How will you access it from outside of EOF?
Chuck
>
> On Aug 11, 2011, at 9:28 AM, Chuck Hill <email@hidden> wrote:
>
>> Hi Riccardo,
>>
>> On 2011-08-11, at 3:53 AM, Riccardo De Menna wrote:
>>
>>> Hi there,
>>>
>>> Is there a way to force the db adaptor to serialize and deserialize objects using java.io.Serializable?
>>> To put it in other words, is there an easy way to serialize simple java objects without the need to write customized code?
>>
>> No. :-)
>>
>> Kieran has a related blog post: http://homepage.mac.com/kelleherk/iblog/C729512539/E2033071041/index.html
>>
>> The summary is that EOF provides for non-Java serialization using these attribute properties set in Entity Modeler:
>> Class:
>> Factory Method::
>> Conversion Method:
>> Init Argument:
>>
>>
>>> For example, I was tweaking some of my prototypes and I just realized that it would be very useful to have an inetAddress prototype for all ip/host addresses. The class for it is java.net.InetAddress and it obviously already implements Serializable. Can I leverage that in entity modeler to save and restore those objects to blobs without having to write a serialization utility?
>>
>> You may get this to work by using getByName as the factory method and getHostName as the conversion method. Otherwise you need to wrap classes like this to serialize and de-serialize using this method OR somehow change EOF to do other serialization (probably possible, probably not easy).
>>
>>
>>> Also, why is the "class" field always disabled in entity modeler when the "value class" is visible?
>>
>> Because that is only for the custom serialization as above.
>>
>>
>>> If there is no automatic way to deserializae using Serializable, then I was thinking of writing a custom serialization class.
>>
>> Patches welcome. :-)
>>
>>
>>> I though I could use the "class" field to point to my deserialization class, the "value class" field to tell the system what to expect as a final output, and the "value type" field to help my class decide "how" to deserialize. But the class field is always grayed out and disabled and I can't find any documentation on how I would have to write my code.
>>
>> Entity Modeler is setup to support what EOF expects which is not what you plan. The com.webobjects.jdbcadaptor.JDBCPlugIn class is one place to start looking if you want to try modifying EOF.
>>
>>
>> Chuck
>>
>>
>> --
>> Chuck Hill Senior Consultant / VP Development
>>
>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>> http://www.global-village.net/products/practical_webobjects
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden