You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by "Brendan Miller (JIRA)" <ji...@apache.org> on 2008/01/15 21:51:34 UTC

[jira] Created: (TORQUE-107) calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)

calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)
---------------------------------------------------------------------------------------------------------------------------------

                 Key: TORQUE-107
                 URL: https://issues.apache.org/jira/browse/TORQUE-107
             Project: Torque
          Issue Type: Bug
          Components: Generator
    Affects Versions: 3.3-RC1
         Environment: RHEL 5, Java 6, Oracle 10g
            Reporter: Brendan Miller
            Priority: Minor


The Object.vm template and generator produce object classes with

   public List<SomeClass> getSomeClasss(Criteria criteria) throws TorqueException

If torque.objectIsCaching is set, this method uses a "last used Criteria" comparison to determine whether or not to re-fetch the Collection of <SomeClass>.  The way the template (Object.vm) is written, we wind up with

   if (!lastSomeClassCriteria.equals(criteria))
   ...

which can throw NullPointerException if this is the first time this method is called (lastSomeClassCriteria will be null).

This could be fixed by changing the comparison to

   if (!criteria.equals(last${relCol}Criteria))

or

   if (last${relCol}Criteria == null || !last${relCol}Criteria.equals(criteria))

Granted, there are other ways to achieve these results (create the appropriate Criteria and call SomeClassPeer.doSelect(Criteria)), but the "getRelatedObjects(Criteria)" method is a handy abstraction that is already generated for each class.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-107) calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)

Posted by "Brendan Miller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566877#action_12566877 ] 

Brendan Miller commented on TORQUE-107:
---------------------------------------

Would the testcase belong in the generator?  I'm trying to think how to simulate this outside of a full-blown application.


> calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TORQUE-107
>                 URL: https://issues.apache.org/jira/browse/TORQUE-107
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3-RC1
>         Environment: RHEL 5, Java 6, Oracle 10g
>            Reporter: Brendan Miller
>            Priority: Minor
>
> The Object.vm template and generator produce object classes with
>    public List<SomeClass> getSomeClasss(Criteria criteria) throws TorqueException
> If torque.objectIsCaching is set, this method uses a "last used Criteria" comparison to determine whether or not to re-fetch the Collection of <SomeClass>.  The way the template (Object.vm) is written, we wind up with
>    if (!lastSomeClassCriteria.equals(criteria))
>    ...
> which can throw NullPointerException if this is the first time this method is called (lastSomeClassCriteria will be null).
> This could be fixed by changing the comparison to
>    if (!criteria.equals(last${relCol}Criteria))
> or
>    if (last${relCol}Criteria == null || !last${relCol}Criteria.equals(criteria))
> Granted, there are other ways to achieve these results (create the appropriate Criteria and call SomeClassPeer.doSelect(Criteria)), but the "getRelatedObjects(Criteria)" method is a handy abstraction that is already generated for each class.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-107) calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)

Posted by "Scott Eade (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566878#action_12566878 ] 

Scott Eade commented on TORQUE-107:
-----------------------------------

Somewhere in test/test-project - see http://db.apache.org/torque/developer-info/test-project.html

> calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TORQUE-107
>                 URL: https://issues.apache.org/jira/browse/TORQUE-107
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3-RC1
>         Environment: RHEL 5, Java 6, Oracle 10g
>            Reporter: Brendan Miller
>            Priority: Minor
>
> The Object.vm template and generator produce object classes with
>    public List<SomeClass> getSomeClasss(Criteria criteria) throws TorqueException
> If torque.objectIsCaching is set, this method uses a "last used Criteria" comparison to determine whether or not to re-fetch the Collection of <SomeClass>.  The way the template (Object.vm) is written, we wind up with
>    if (!lastSomeClassCriteria.equals(criteria))
>    ...
> which can throw NullPointerException if this is the first time this method is called (lastSomeClassCriteria will be null).
> This could be fixed by changing the comparison to
>    if (!criteria.equals(last${relCol}Criteria))
> or
>    if (last${relCol}Criteria == null || !last${relCol}Criteria.equals(criteria))
> Granted, there are other ways to achieve these results (create the appropriate Criteria and call SomeClassPeer.doSelect(Criteria)), but the "getRelatedObjects(Criteria)" method is a handy abstraction that is already generated for each class.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-107) calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)

Posted by "Scott Eade (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566449#action_12566449 ] 

Scott Eade commented on TORQUE-107:
-----------------------------------

Would it be possible to provide a test case for this.

> calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TORQUE-107
>                 URL: https://issues.apache.org/jira/browse/TORQUE-107
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3-RC1
>         Environment: RHEL 5, Java 6, Oracle 10g
>            Reporter: Brendan Miller
>            Priority: Minor
>
> The Object.vm template and generator produce object classes with
>    public List<SomeClass> getSomeClasss(Criteria criteria) throws TorqueException
> If torque.objectIsCaching is set, this method uses a "last used Criteria" comparison to determine whether or not to re-fetch the Collection of <SomeClass>.  The way the template (Object.vm) is written, we wind up with
>    if (!lastSomeClassCriteria.equals(criteria))
>    ...
> which can throw NullPointerException if this is the first time this method is called (lastSomeClassCriteria will be null).
> This could be fixed by changing the comparison to
>    if (!criteria.equals(last${relCol}Criteria))
> or
>    if (last${relCol}Criteria == null || !last${relCol}Criteria.equals(criteria))
> Granted, there are other ways to achieve these results (create the appropriate Criteria and call SomeClassPeer.doSelect(Criteria)), but the "getRelatedObjects(Criteria)" method is a handy abstraction that is already generated for each class.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


[jira] Commented: (TORQUE-107) calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)

Posted by "Scott Eade (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/TORQUE-107?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12566870#action_12566870 ] 

Scott Eade commented on TORQUE-107:
-----------------------------------

I can't see an obvious way to make this happen, so a test case will definitely be required.

> calling getRelatedObjects(Criteria) can result in NullPointerException if the collection has not be initialized (with a Criteria)
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: TORQUE-107
>                 URL: https://issues.apache.org/jira/browse/TORQUE-107
>             Project: Torque
>          Issue Type: Bug
>          Components: Generator
>    Affects Versions: 3.3-RC1
>         Environment: RHEL 5, Java 6, Oracle 10g
>            Reporter: Brendan Miller
>            Priority: Minor
>
> The Object.vm template and generator produce object classes with
>    public List<SomeClass> getSomeClasss(Criteria criteria) throws TorqueException
> If torque.objectIsCaching is set, this method uses a "last used Criteria" comparison to determine whether or not to re-fetch the Collection of <SomeClass>.  The way the template (Object.vm) is written, we wind up with
>    if (!lastSomeClassCriteria.equals(criteria))
>    ...
> which can throw NullPointerException if this is the first time this method is called (lastSomeClassCriteria will be null).
> This could be fixed by changing the comparison to
>    if (!criteria.equals(last${relCol}Criteria))
> or
>    if (last${relCol}Criteria == null || !last${relCol}Criteria.equals(criteria))
> Granted, there are other ways to achieve these results (create the appropriate Criteria and call SomeClassPeer.doSelect(Criteria)), but the "getRelatedObjects(Criteria)" method is a handy abstraction that is already generated for each class.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org