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 "Craig Russell (JIRA)" <ji...@apache.org> on 2008/11/06 17:26:01 UTC
[jira] Commented: (JDO-611) GetObjectIdForPersistentInterface -
Implementation Class / PICompany / ICompany Mess
[ https://issues.apache.org/jira/browse/JDO-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12645503#action_12645503 ]
Craig Russell commented on JDO-611:
-----------------------------------
For easy reference, this is the test case method:
public void testGetObjectId() {
if (!runsWithApplicationIdentity()) {
printNonApplicableIdentityType(
"GetObjectIdForPersistentInterface",
APPLICATION_IDENTITY);
return;
}
pm = getPM();
Transaction tx = pm.currentTransaction();
ICompany icompany = (ICompany)pm.newInstance(ICompany.class);
icompany.setCompanyid(1001);
icompany.setName("GooTube");
icompany.setFounded(new Date());
tx.begin();
pm.makePersistent(icompany);
LongIdentity ioid = (LongIdentity)pm.getObjectId(icompany);
tx.commit();
Class icompanyOidClass = ioid.getTargetClass();
if (icompanyOidClass != icompany.getClass())
appendMessage(ASSERTION_FAILED +
" getObjectId(icompany) should return interface class.\n" +
"expected: " + icompany.getClass().getName() + "\n" +
"actual: " + icompanyOidClass.getName());
failOnError();
a) and b) I agree. The ICompany interface isn't persistent, so the newInstance and addTearDownClass should use PICompany instead of ICompany.
c) I agree that the check is wrong. Here's the spec:
<spec>
For interfaces and classes that use a SingleFieldIdentity as the object-id class, if the returned in-
stance is subsequently made persistent, the target class stored in the object-id instance is the param-
eter of the newInstance method that created it.
</spec>
So the check should verify that the target class for the oid instance is the PICompany.class (with changes as above). Here's what I'd propose to change:
if (icompanyOidClass != PICompany.class)
Actually, I'd like to change the variable name to pICompanyOidTargetClass so it's clear that the class being retrieved from the oid instance is the target class.
WDYT?
> GetObjectIdForPersistentInterface - Implementation Class / PICompany / ICompany Mess
> -------------------------------------------------------------------------------------
>
> Key: JDO-611
> URL: https://issues.apache.org/jira/browse/JDO-611
> Project: JDO
> Issue Type: Test
> Components: tck2
> Affects Versions: JDO 2 maintenance release 2
> Reporter: Ilan Kirsh
>
> I have two issues with this test:
> (1)
> IMO, PICompany should be written instead of ICompany:
> (a)
> ICompany icompany = (ICompany)pm.newInstance(PICompany.class);
> instead of:
> ICompany icompany = (ICompany)pm.newInstance(ICompany.class);
> and:
> (b)
> addTearDownClass(PICompany.class);
> instead of:
> addTearDownClass(ICompany.class);
> ICompany is not persistence capable, so the implementation does not have to handle it.
> (2)
> I think that the following check is wrong:
> if (icompanyOidClass != icompany.getClass())
> icompany.getClass() => the physical internal implementation class
> icompanyOidClass => the logical interface (PICompany)
> Actually and exception should be thrown if (icompanyOidClass == icompany.getClass())
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.