[jira] Created: (JDO-630) Support specification of exact class in SingleFieldIdentity

View: New views
10 Messages — Rating Filter:   Alert me  

[jira] Created: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Support specification of exact class in SingleFieldIdentity
-----------------------------------------------------------

                 Key: JDO-630
                 URL: https://issues.apache.org/jira/browse/JDO-630
             Project: JDO
          Issue Type: Improvement
          Components: api2
            Reporter: Andy Jefferson
             Fix For: JDO 2 maintenance release 3


When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
(if the implementation decides to do so):
"It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."

Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?

It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
void setExact(boolean flag);
boolean getExact();
to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Jefferson updated JDO-630:
-------------------------------

    Attachment: singlefieldidentity_exact.patch

Patch for SingleFieldIdentity as per the description

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: api2
>            Reporter: Andy Jefferson
>             Fix For: JDO 2 maintenance release 3
>
>         Attachments: singlefieldidentity_exact.patch
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702375#action_12702375 ]

Andy Jefferson commented on JDO-630:
------------------------------------

Since in the weekly meeting minutes people were wanting an identity to be non-mutable from construction and after studying the usage of such identities I've come to the conclusion that it would probably be better to just add a new method on the PM (as per the original mailing list request - 22/07/2008). The only place a SingleFieldIdentity "id" can be considered "not exact" is where the user has input it into PM.getObject[s]ById(...) AFAICS. All objects returned by the implementation will have exact ids. All ids returned by PM.getObjectId() will also be exact.

This would imply adding the following :-
Object getObjectById(String id, boolean validate, boolean checkInheritance);
Object[] getObjectsById(boolean validate, boolean checkInheritance, Object... ids);

The other benefit of this would be in terms of memory, one boolean less overhead per object.

Comments ?

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: api2
>            Reporter: Andy Jefferson
>             Fix For: JDO 2 maintenance release 3
>
>         Attachments: singlefieldidentity_exact.patch
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702456#action_12702456 ]

Craig Russell commented on JDO-630:
-----------------------------------

> All objects returned by the implementation will have exact ids. All ids returned by PM.getObjectId() will also be exact.

This seems to be the right direction. But there are a few APIs that we should revisit. Here's a proposal to change the spec but leave the API exactly as it is:

    Object getObjectById (Object oid, boolean validate);
Add to the description of validate false:
The user asserts that the oid contains the exact id, so if the object is not in the cache, the implementation constructs a hollow instance of the class in the oid. If the class is abstract, throw StupidUserException (we cannot construct a hollow instance of an abstract class). If the class is actually not correct, an exception with a possibly confusing error message might be thrown later. Caveat user. Test case needed.

    <T> T getObjectById (Class<T> cls, Object key);
This is already described as having identical behavior to pm.getObjectById (pm.newObjectIdInstance (cls, key), true), so no change.

    Object getObjectById (Object oid);
This is already described as having identical behavior to pm.getObjectById(oid, true), so no change.

    Object[] getObjectsById (boolean validate, Object... oids);
This is defined as iterating the oids and calling getObjectById(oid, validate) so no change.

    Collection getObjectsById (Collection oids);
This is already described as having identical behavior to pm.getObjecstById(true, oids), so no change.



> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: api2
>            Reporter: Andy Jefferson
>             Fix For: JDO 2 maintenance release 3
>
>         Attachments: singlefieldidentity_exact.patch
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703789#action_12703789 ]

Andy Jefferson commented on JDO-630:
------------------------------------

This behaviour is implemented in the RI.

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: api2
>            Reporter: Andy Jefferson
>             Fix For: JDO 2 maintenance release 3
>
>         Attachments: singlefieldidentity_exact.patch
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Bouschen updated JDO-630:
---------------------------------

    Component/s:     (was: api2)
                 specification

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: specification
>            Reporter: Andy Jefferson
>             Fix For: JDO 2 maintenance release 3
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Craig Russell reassigned JDO-630:
---------------------------------

    Assignee: Craig Russell

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: specification
>            Reporter: Andy Jefferson
>            Assignee: Craig Russell
>             Fix For: JDO 2 maintenance release 3
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Jefferson updated JDO-630:
-------------------------------

    Attachment:     (was: singlefieldidentity_exact.patch)

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: specification
>            Reporter: Andy Jefferson
>            Assignee: Craig Russell
>             Fix For: JDO 2 maintenance release 3
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


    [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12721871#action_12721871 ]

Craig Russell commented on JDO-630:
-----------------------------------

To test this feature:
Add an instance of FullTimeEmployee with identity 1.

Object oid = new LongIdentity(PartTimeEmployee.class, 1);

try {
PartTimeEmployee pto = pm.getObjectById(oid, false);
pto.getName();
} catch (JDOException ex) {
// must fail
}

try {
Object oid = new IntIdentity(PartTimeEmployee.class, 1);
} catch (JDOException ex) {
// must fail
}

Other cases with Person must also fail.



> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: specification
>            Reporter: Andy Jefferson
>            Assignee: Craig Russell
>             Fix For: JDO 2 maintenance release 3
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JDO-630) Support specification of exact class in SingleFieldIdentity

by JIRA jira@apache.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


     [ https://issues.apache.org/jira/browse/JDO-630?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Bouschen updated JDO-630:
---------------------------------

    Component/s: tck2

> Support specification of exact class in SingleFieldIdentity
> -----------------------------------------------------------
>
>                 Key: JDO-630
>                 URL: https://issues.apache.org/jira/browse/JDO-630
>             Project: JDO
>          Issue Type: Improvement
>          Components: specification, tck2
>            Reporter: Andy Jefferson
>            Assignee: Craig Russell
>             Fix For: JDO 2 maintenance release 3
>
>
> When calling PersistenceManager.getObjectById() with a SingleFieldIdentity, there seems to be no way of avoiding the following
> (if the implementation decides to do so):
> "It is an implementation decision whether to access the data store, if required to determine the exact class. This will be the case of  inheritance, where multiple <code>PersistenceCapable</code> classes share the same ObjectId class."
> Now when I know for sure that the targetClassName of the given SingleFieldIdentity already denotes the correct class for the given id,  how can I avoid that additional roundtrip to the database for finding the exact class?
> It would be useful to have a way of specifying a SingleFieldIdentity to be for the exact class specified. This could be done by addition of methods
> void setExact(boolean flag);
> boolean getExact();
> to SingleFieldIdentity

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.