You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-dev@db.apache.org by Andy Jefferson <an...@jpox.org> on 2005/08/16 20:11:36 UTC

Re: Support java.lang.Object as FCO

> > What if we define a new attribute on field called field-type, and for
> > the TCK we put in "...SimpleClass"? Would that allow you to map it?

> It certainly sounds doable (not looked at the code ...).

OK, JPOX now supports java.lang.Object as FCO. It's not currently using the 
proposed <field> attribute to notate which classes will actually be stored in 
that field, instead using
<field name="myObjectField>
    <extension vendor-name="jpox" key="implementation-classes" 
value="comma-separated-list-of-PC-classnames-that-can-be-stored-here"/>
</field>

When we have an agreed JDO2 attribute, I'll swap it over to that.

The TCK now gives exceptions of the following style, due to absence of 
possible classes against each Object (or Collection of Object) field :-
javax.jdo.JDOUserException: Field 
"org.apache.jdo.tck.pc.fieldtypes.ArrayListCollections.ArrayListOfObject2" is 
declared as a reference type (interface/Object) but no implementation classes 
of "java.lang.Object" have been found!

HTH
-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Craig Russell <Cr...@Sun.COM>.
Hi,

Very cool.

Craig

On Aug 16, 2005, at 12:18 PM, Andy Jefferson wrote:

>> Very nice!  Is the change available for download now, or just  
>> checked in?
>>
>
> Hi Michelle,
>
> the majority of the changes were in last nights build, but some  
> further
> updates were made today - so it would be safer to just get the  
> build dated
> 17/08 onwards
>
> -- 
> Andy
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Support java.lang.Object as FCO

Posted by Andy Jefferson <an...@jpox.org>.
> Very nice!  Is the change available for download now, or just checked in?

Hi Michelle,

the majority of the changes were in last nights build, but some further 
updates were made today - so it would be safer to just get the build dated 
17/08 onwards

-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Andy Jefferson <an...@jpox.org>.
> Well we interpret all types as serialized="false", but in section 18.14 of
> the spec "java.lang" types (which Object is) are to be embedded="true" by
> default. So we interpret this as serialising the Object into the table of
> the class, into a BLOB column.

Michelle,
before you change anything .... (was writing this while I received your reply)


That, of course, comes down to how you interpret the statement in the section 
embedding 18.14.
<spec>
The embedded attribute specifies whether the field should be stored as part of 
the containing instance instead of as its own instance in the datastore. It 
must be specified or default to "true" for fields of primitive types, 
wrappers, java.lang, java.math, java.util, collection, map, and array types 
specified above; and “false” otherwise. Thus, specifying this attribute is 
not usually necessary. While a compliant implementation is permitted to 
support these types as first class instances in the datastore, the semantics 
of embedded=”true” imply containment. That is, the embedded instances have no 
independent existence in the datastore and have no Extent representation.
</spec>

Depends if it means the "java.lang, java.math, ... types specified above" (i.e 
all of the specific types specified above), or if it means "array types 
specified above" (just the last part applying to the "specified above"). 
Since I've got a teaching qualification in English, I'm opting for the 
latter, but maybe our local spec author can clarify the intent  ;-)

-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,

> I've enhanced the spec as follows:
> The embedded attribute specifies whether the field should be stored
> as part of the containing instance instead of as its own instance in
> the datastore. It must be specified or default to "true" for fields
> of primitive types, wrappers, java.lang, java.math, java.util,
> collection, map, and array types specified above; and “false” for
> other types including persistence-capable types, interface types and
> the Object type.

Yes, this defines how the user specifies that a field is to be embedded. No 
problems there.

> Embedded is different from serialized. I've proposed a spec change to
> that effect. I think that people would be surprised to find embedded
> objects were actually serialized in this case, as embedded PC types
> like Address are handled very differently elsewhere in the spec
> (using the <embedded> element).

Yes, I'm aware that there are 2 ways we can do it. All my point was is that 
the spec currently says that an embedded instance is "stored as part of the 
containing instance". That's fine too, on its own, but it doesn't distinguish 
it from a serialized instance, which is also "stored as part of the 
containing instance" (though in one column). I think we should have a 
description of an embedded, referring to it being mapped column-by-column 
(where it is of PC, Object or Interface type) to distinguish it from 
serialized.


The other detail I feel is lacking from the spec is how the embedded="true" 
and <embedded> interrelate. Suppose I have a PC class which has a PC 
field ...

1. If I specify the PC field as embedded="true" but omit the <embedded> 
element, this presumably allows the JDO impl to either map the fields of the 
embedded PC field as it decides (since the user has provided no mapping 
details), or to require the user to define the <embedded> element.

2. Specifying the <embedded> element, but not specifying the embedded="true" 
will presumably result in the field being embedded (i.e specifying the 
<embedded> element is effectively setting embedded="true"). The description 
of <embedded> in Ch18 says that the <embedded> specifies the mapping for an 
embedded type. It doesn't say anything about whether the user needs to make 
the type embedded="true" for this element to be used.

3. If I specify the PC field with just an <embedded> element, and the PC to be 
embedded has 10 fields that are persistence-modifier="persistent" but the 
user only specifies 6 of them in the <embedded>, presumably the JDO impl will 
be expected to map the others.

> The spec doesn't call out whether support for embedded Object or
> embedded interfaces is required. I don't think it should be required,
> but then we need a way to identify an implementation as supporting
> this feature. Something like
> javax.jdo.options.mapping.EmbeddedInterface and ...EmbeddedObject.

Agreed.


-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Craig Russell <Cr...@Sun.COM>.
Hi Andy,

Thanks for your thoughtful insights here.

It appears we are in sync for supporting field types of Object as  
FCO, and now we're discussing support for Object as SCO (embedded).

On Aug 17, 2005, at 11:26 PM, Andy Jefferson wrote:

> Hi Craig,
>
>
>>> Well we interpret all types as serialized="false", but in section
>>> 18.14 of the
>>> spec "java.lang" types (which Object is) are to be  
>>> embedded="true" by
>>> default. So we interpret this as serialising the Object into the
>>> table of the
>>> class, into a BLOB column.
>>>
>>
>> I tried to be more explicit about this in the Proposed Final Draft,
>> to say that embedded="true" doesn't mean serialized but embedded
>> column by column. Just like embedded PC instances.
>>
>
> OK, but the issue here is whether "java.lang.Object" defaults to
> embedded="true" or embedded="false". The wording at the start of  
> the section
> 18.14 Embedded can be interpreted 2 ways. That java.lang.Object is  
> embedded
> by default, or it isn't.

I've enhanced the spec as follows:
The embedded attribute specifies whether the field should be stored  
as part of the containing instance instead of as its own instance in  
the datastore. It must be specified or default to "true" for fields  
of primitive types, wrappers, java.lang, java.math, java.util,  
collection, map, and array types specified above; and “false” for  
other types including persistence-capable types, interface types and  
the Object type.
>
> Looking at some of the JDO1 books, Object is *not* embedded by  
> default, so
> I've updated JPOX to reflect this (in last nights build -  
> 18/08/2005). This
> gets around the immediate issue that Michelle raised.

This is consistent with what the spec intended.
>
>
> When we have an Object field that is marked as embedded="true" JPOX  
> will
> currently serialise it into a single column - since we don't support
> embedding it column by column into the owning table.

Embedded is different from serialized. I've proposed a spec change to  
that effect. I think that people would be surprised to find embedded  
objects were actually serialized in this case, as embedded PC types  
like Address are handled very differently elsewhere in the spec  
(using the <embedded> element).

> I looked at the PFD and
> couldn't decide if this is valid or not. You're saying that we  
> should embed
> the Object column-by-column.
>
> We have 2 situations
> <field name="myObjectField" embedded="true"/>
> This one we treat as serialised currently since no embedded  
> definition is
> available
>
> <field name="myObjectField">
>     <embedded>
>         ...
>     </embedded>
> </field>
> This we do not support since the Object field could have multiple
> "implementations" stored there, so the fields will vary. For the  
> same reason
> we don't support the same situations with interface fields

The spec doesn't call out whether support for embedded Object or  
embedded interfaces is required. I don't think it should be required,  
but then we need a way to identify an implementation as supporting  
this feature. Something like  
javax.jdo.options.mapping.EmbeddedInterface and ...EmbeddedObject.

Craig
>
>
>
> -- 
> Andy
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Support java.lang.Object as FCO

Posted by Andy Jefferson <an...@jpox.org>.
Hi Craig,

> > Well we interpret all types as serialized="false", but in section
> > 18.14 of the
> > spec "java.lang" types (which Object is) are to be embedded="true" by
> > default. So we interpret this as serialising the Object into the
> > table of the
> > class, into a BLOB column.
>
> I tried to be more explicit about this in the Proposed Final Draft,
> to say that embedded="true" doesn't mean serialized but embedded
> column by column. Just like embedded PC instances.

OK, but the issue here is whether "java.lang.Object" defaults to 
embedded="true" or embedded="false". The wording at the start of the section 
18.14 Embedded can be interpreted 2 ways. That java.lang.Object is embedded 
by default, or it isn't. 

Looking at some of the JDO1 books, Object is *not* embedded by default, so 
I've updated JPOX to reflect this (in last nights build - 18/08/2005). This 
gets around the immediate issue that Michelle raised.


When we have an Object field that is marked as embedded="true" JPOX will 
currently serialise it into a single column - since we don't support 
embedding it column by column into the owning table. I looked at the PFD and 
couldn't decide if this is valid or not. You're saying that we should embed 
the Object column-by-column.

We have 2 situations
<field name="myObjectField" embedded="true"/>
This one we treat as serialised currently since no embedded definition is 
available

<field name="myObjectField">
    <embedded>
        ...
    </embedded>
</field>
This we do not support since the Object field could have multiple 
"implementations" stored there, so the fields will vary. For the same reason 
we don't support the same situations with interface fields



-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Michelle Caisse <Mi...@Sun.COM>.
Craig Russell wrote:

> Hi Michelle,
>
> On Aug 17, 2005, at 3:14 PM, Michelle Caisse wrote:
>
>> Maybe this belongs in Chapter 15.
>
>
> I've been thinking of Chapter 15 as non-normative. All the required  
> behavior should be in chapter 18. What do you think?


Yup, I agree.  -- Michelle

>
> Craig
>
>>
>> -- Michelle
>


Re: Support java.lang.Object as FCO

Posted by Craig Russell <Cr...@Sun.COM>.
Hi Michelle,

On Aug 17, 2005, at 3:14 PM, Michelle Caisse wrote:

> Hi Craig,
>
> I think the spec could be more explicit.

I agree. I'm trying to make it so.

> Embedded and serialized are syntactically orthogonal but not  
> semantically orthogonal;  therefore, they should be discussed  
> together somewhere.

Good idea.

> The spec should state that embedded="true" and serialized="true"  
> are mutually exclusive.

I agree.

> Also a discussion of the meaning of embedded="false"  
> serialized="false" for PC instances would be useful.

This discussion needs to include embedded-value, embedded-key, and  
embedded-element. And I agree. This is an issue that I added to the  
"to be resolved before FCS" of the JDO spec.

> Maybe this belongs in Chapter 15.

I've been thinking of Chapter 15 as non-normative. All the required  
behavior should be in chapter 18. What do you think?

Craig
>
> -- Michelle
>
> Craig Russell wrote:
>
>
>> Hi Andy,
>>
>> On Aug 17, 2005, at 10:39 AM, Andy Jefferson wrote:
>>
>>
>>> Hi Michelle,
>>>
>>>
>>>
>>>> It seems that jpox maps Object as serialized by default.  Where   
>>>> there is
>>>> no serialized or embedded attribute on the field, we map to a  
>>>> FK  column,
>>>> e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:
>>>>
>>>>
>>>
>>> Well we interpret all types as serialized="false", but in  
>>> section  18.14 of the
>>> spec "java.lang" types (which Object is) are to be  
>>> embedded="true" by
>>> default. So we interpret this as serialising the Object into the   
>>> table of the
>>> class, into a BLOB column.
>>>
>>
>>
>> I tried to be more explicit about this in the Proposed Final  
>> Draft,  to say that embedded="true" doesn't mean serialized but  
>> embedded  column by column. Just like embedded PC instances.
>>
>> Could you please take a look at the PFD and see if this is not  
>> clear  enough?
>>
>> Thanks,
>>
>> Craig
>>
>>
>>>
>>>
>>>
>>>> SimpleInterface, which we map identically to Object, works fine.
>>>>
>>>>
>>>
>>> Because we treat an Interface as embedded="false" by default  
>>> (since  it's not
>>> specified in the list of embedded types in 18.14, so its  
>>> effectively a
>>> PersistenceCapable in that respect).
>>>
>>>
>>> -- 
>>> Andy
>>>
>>>
>>
>> Craig Russell
>> Architect, Sun Java Enterprise System http://java.sun.com/products/ 
>> jdo
>> 408 276-5638 mailto:Craig.Russell@sun.com
>> P.S. A good JDO? O, Gasp!
>>
>>
>>
>
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Support java.lang.Object as FCO

Posted by Michelle Caisse <Mi...@Sun.COM>.
Hi Craig,

I think the spec could be more explicit.  Embedded and serialized are 
syntactically orthogonal but not semantically orthogonal,  therefore 
they should be discussed together somewhere. The spec should state that 
embedded="true" and serialized="true" are mutually exclusive.  Also a 
discussion of the meaning of embedded="false" serialized="false" for PC 
instances would be useful.  Maybe this belongs in Chapter 15.

-- Michelle

Craig Russell wrote:

> Hi Andy,
>
> On Aug 17, 2005, at 10:39 AM, Andy Jefferson wrote:
>
>> Hi Michelle,
>>
>>
>>> It seems that jpox maps Object as serialized by default.  Where  
>>> there is
>>> no serialized or embedded attribute on the field, we map to a FK  
>>> column,
>>> e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:
>>>
>>
>> Well we interpret all types as serialized="false", but in section  
>> 18.14 of the
>> spec "java.lang" types (which Object is) are to be embedded="true" by
>> default. So we interpret this as serialising the Object into the  
>> table of the
>> class, into a BLOB column.
>
>
> I tried to be more explicit about this in the Proposed Final Draft,  
> to say that embedded="true" doesn't mean serialized but embedded  
> column by column. Just like embedded PC instances.
>
> Could you please take a look at the PFD and see if this is not clear  
> enough?
>
> Thanks,
>
> Craig
>
>>
>>
>>> SimpleInterface, which we map identically to Object, works fine.
>>>
>>
>> Because we treat an Interface as embedded="false" by default (since  
>> it's not
>> specified in the list of embedded types in 18.14, so its effectively a
>> PersistenceCapable in that respect).
>>
>>
>> -- 
>> Andy
>>
>
> Craig Russell
> Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
> 408 276-5638 mailto:Craig.Russell@sun.com
> P.S. A good JDO? O, Gasp!
>
>


Re: Support java.lang.Object as FCO

Posted by Craig Russell <Cr...@Sun.COM>.
Hi Andy,

On Aug 17, 2005, at 10:39 AM, Andy Jefferson wrote:

> Hi Michelle,
>
>
>> It seems that jpox maps Object as serialized by default.  Where  
>> there is
>> no serialized or embedded attribute on the field, we map to a FK  
>> column,
>> e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:
>>
>
> Well we interpret all types as serialized="false", but in section  
> 18.14 of the
> spec "java.lang" types (which Object is) are to be embedded="true" by
> default. So we interpret this as serialising the Object into the  
> table of the
> class, into a BLOB column.

I tried to be more explicit about this in the Proposed Final Draft,  
to say that embedded="true" doesn't mean serialized but embedded  
column by column. Just like embedded PC instances.

Could you please take a look at the PFD and see if this is not clear  
enough?

Thanks,

Craig
>
>
>> SimpleInterface, which we map identically to Object, works fine.
>>
>
> Because we treat an Interface as embedded="false" by default (since  
> it's not
> specified in the list of embedded types in 18.14, so its effectively a
> PersistenceCapable in that respect).
>
>
> -- 
> Andy
>

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Support java.lang.Object as FCO

Posted by Michelle Caisse <Mi...@Sun.COM>.
Thanks!  I will change the metadata.  -- Michelle

Andy Jefferson wrote:

>Hi Michelle,
>
>  
>
>>It seems that jpox maps Object as serialized by default.  Where there is
>>no serialized or embedded attribute on the field, we map to a FK column,
>>e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:
>>    
>>
>
>Well we interpret all types as serialized="false", but in section 18.14 of the 
>spec "java.lang" types (which Object is) are to be embedded="true" by 
>default. So we interpret this as serialising the Object into the table of the 
>class, into a BLOB column.
>
>  
>
>>SimpleInterface, which we map identically to Object, works fine.
>>    
>>
>
>Because we treat an Interface as embedded="false" by default (since it's not 
>specified in the list of embedded types in 18.14, so its effectively a 
>PersistenceCapable in that respect).
>
>
>  
>


Re: Support java.lang.Object as FCO

Posted by Andy Jefferson <an...@jpox.org>.
Hi Michelle,

> It seems that jpox maps Object as serialized by default.  Where there is
> no serialized or embedded attribute on the field, we map to a FK column,
> e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:

Well we interpret all types as serialized="false", but in section 18.14 of the 
spec "java.lang" types (which Object is) are to be embedded="true" by 
default. So we interpret this as serialising the Object into the table of the 
class, into a BLOB column.

> SimpleInterface, which we map identically to Object, works fine.

Because we treat an Interface as embedded="false" by default (since it's not 
specified in the list of embedded types in 18.14, so its effectively a 
PersistenceCapable in that respect).


-- 
Andy

Re: Support java.lang.Object as FCO

Posted by Michelle Caisse <Mi...@Sun.COM>.
Very nice!  Is the change available for download now, or just checked in?

-- Michelle

Andy Jefferson wrote:

>>>What if we define a new attribute on field called field-type, and for
>>>the TCK we put in "...SimpleClass"? Would that allow you to map it?
>>>      
>>>
>
>  
>
>>It certainly sounds doable (not looked at the code ...).
>>    
>>
>
>OK, JPOX now supports java.lang.Object as FCO. It's not currently using the 
>proposed <field> attribute to notate which classes will actually be stored in 
>that field, instead using
><field name="myObjectField>
>    <extension vendor-name="jpox" key="implementation-classes" 
>value="comma-separated-list-of-PC-classnames-that-can-be-stored-here"/>
></field>
>
>When we have an agreed JDO2 attribute, I'll swap it over to that.
>
>The TCK now gives exceptions of the following style, due to absence of 
>possible classes against each Object (or Collection of Object) field :-
>javax.jdo.JDOUserException: Field 
>"org.apache.jdo.tck.pc.fieldtypes.ArrayListCollections.ArrayListOfObject2" is 
>declared as a reference type (interface/Object) but no implementation classes 
>of "java.lang.Object" have been found!
>
>HTH
>  
>


Re: Support java.lang.Object as FCO

Posted by Michelle Caisse <Mi...@Sun.COM>.
Hi Andy,

It seems that jpox maps Object as serialized by default.  Where there is 
no serialized or embedded attribute on the field, we map to a FK column, 
e.g. OBJECT102 BIGINT REFERENCES SIMPLE_CLASS, giving a jpox error:

    An attempt was made to put a data value of type 'byte[]' into a data 
value of type 'BIGINT'.

SimpleInterface, which we map identically to Object, works fine.

-- Michelle

Andy Jefferson wrote:

>>>What if we define a new attribute on field called field-type, and for
>>>the TCK we put in "...SimpleClass"? Would that allow you to map it?
>>>      
>>>
>
>  
>
>>It certainly sounds doable (not looked at the code ...).
>>    
>>
>
>OK, JPOX now supports java.lang.Object as FCO. It's not currently using the 
>proposed <field> attribute to notate which classes will actually be stored in 
>that field, instead using
><field name="myObjectField>
>    <extension vendor-name="jpox" key="implementation-classes" 
>value="comma-separated-list-of-PC-classnames-that-can-be-stored-here"/>
></field>
>
>When we have an agreed JDO2 attribute, I'll swap it over to that.
>
>The TCK now gives exceptions of the following style, due to absence of 
>possible classes against each Object (or Collection of Object) field :-
>javax.jdo.JDOUserException: Field 
>"org.apache.jdo.tck.pc.fieldtypes.ArrayListCollections.ArrayListOfObject2" is 
>declared as a reference type (interface/Object) but no implementation classes 
>of "java.lang.Object" have been found!
>
>HTH
>  
>