You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Peter Kelley (JIRA)" <ji...@apache.org> on 2009/04/25 05:39:31 UTC

[jira] Created: (WW-3098) NeedsRefresh not working for ModelDrivenInterceptor and Hibernate

NeedsRefresh not working for ModelDrivenInterceptor and Hibernate
-----------------------------------------------------------------

                 Key: WW-3098
                 URL: https://issues.apache.org/struts/browse/WW-3098
             Project: Struts 2
          Issue Type: Bug
          Components: Core Interceptors
    Affects Versions: 2.1.6
         Environment: Hibernate
JPA
Windows XP
Tomcat 6 running under Eclipse 3.4
Java 1.6 with Java 1.5 source compliance
            Reporter: Peter Kelley


I have the following configured in struts.xml:

                <interceptor-ref name="Driven">
                    <!-- allow actions to change the model during execution so that the view gets a new model. --> 
                    <param name="refreshModelBeforeResult">true</param>
                </interceptor-ref>

and in my action:
    /**
     * Create or update the entity.
     * 
     * @return <code>Show</code>
     */
    public String save() {
        LOG.debug("save() Called");
        setEntity(getDao().save(entity));
        return SHOW;
    }

Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.

When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):

            // Check to see if the new model instance is already on the stack
            for (Object item : root) {
                if (item == newModel) {
                    needsRefresh = false;
                }
            }

the test equates to true even though I can see in the debugger that the two objects have different object identities.

Changing line 114 to:

                if (item.equals(newModel)) {

fixes the problem.

I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.

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


[jira] Updated: (WW-3098) NeedsRefresh not working for ModelDrivenInterceptor and Hibernate

Posted by "Peter Kelley (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3098?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Peter Kelley updated WW-3098:
-----------------------------

    Description: 
I have the following configured in struts.xml:

                <interceptor-ref name="modelDriven">
                    <!-- allow actions to change the model during execution so that the view gets a new model. --> 
                    <param name="refreshModelBeforeResult">true</param>
                </interceptor-ref>

and in my action:
    /**
     * Create or update the entity.
     * 
     * @return <code>Show</code>
     */
    public String save() {
        LOG.debug("save() Called");
        setEntity(getDao().save(entity));
        return SHOW;
    }

Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.

When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):

            // Check to see if the new model instance is already on the stack
            for (Object item : root) {
                if (item == newModel) {
                    needsRefresh = false;
                }
            }

the test equates to true even though I can see in the debugger that the two objects have different object identities.

Changing line 114 to:

                if (item.equals(newModel)) {

fixes the problem.

I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.

  was:
I have the following configured in struts.xml:

                <interceptor-ref name="Driven">
                    <!-- allow actions to change the model during execution so that the view gets a new model. --> 
                    <param name="refreshModelBeforeResult">true</param>
                </interceptor-ref>

and in my action:
    /**
     * Create or update the entity.
     * 
     * @return <code>Show</code>
     */
    public String save() {
        LOG.debug("save() Called");
        setEntity(getDao().save(entity));
        return SHOW;
    }

Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.

When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):

            // Check to see if the new model instance is already on the stack
            for (Object item : root) {
                if (item == newModel) {
                    needsRefresh = false;
                }
            }

the test equates to true even though I can see in the debugger that the two objects have different object identities.

Changing line 114 to:

                if (item.equals(newModel)) {

fixes the problem.

I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.


> NeedsRefresh not working for ModelDrivenInterceptor and Hibernate
> -----------------------------------------------------------------
>
>                 Key: WW-3098
>                 URL: https://issues.apache.org/struts/browse/WW-3098
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.6
>         Environment: Hibernate
> JPA
> Windows XP
> Tomcat 6 running under Eclipse 3.4
> Java 1.6 with Java 1.5 source compliance
>            Reporter: Peter Kelley
>
> I have the following configured in struts.xml:
>                 <interceptor-ref name="modelDriven">
>                     <!-- allow actions to change the model during execution so that the view gets a new model. --> 
>                     <param name="refreshModelBeforeResult">true</param>
>                 </interceptor-ref>
> and in my action:
>     /**
>      * Create or update the entity.
>      * 
>      * @return <code>Show</code>
>      */
>     public String save() {
>         LOG.debug("save() Called");
>         setEntity(getDao().save(entity));
>         return SHOW;
>     }
> Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.
> When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):
>             // Check to see if the new model instance is already on the stack
>             for (Object item : root) {
>                 if (item == newModel) {
>                     needsRefresh = false;
>                 }
>             }
> the test equates to true even though I can see in the debugger that the two objects have different object identities.
> Changing line 114 to:
>                 if (item.equals(newModel)) {
> fixes the problem.
> I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.

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


[jira] Resolved: (WW-3098) NeedsRefresh not working for ModelDrivenInterceptor and Hibernate

Posted by "Musachy Barroso (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3098?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Musachy Barroso resolved WW-3098.
---------------------------------

    Resolution: Fixed

> NeedsRefresh not working for ModelDrivenInterceptor and Hibernate
> -----------------------------------------------------------------
>
>                 Key: WW-3098
>                 URL: https://issues.apache.org/struts/browse/WW-3098
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.6
>         Environment: Hibernate
> JPA
> Windows XP
> Tomcat 6 running under Eclipse 3.4
> Java 1.6 with Java 1.5 source compliance
>            Reporter: Peter Kelley
>             Fix For: 2.1.8
>
>
> I have the following configured in struts.xml:
>                 <interceptor-ref name="modelDriven">
>                     <!-- allow actions to change the model during execution so that the view gets a new model. --> 
>                     <param name="refreshModelBeforeResult">true</param>
>                 </interceptor-ref>
> and in my action:
>     /**
>      * Create or update the entity.
>      * 
>      * @return <code>Show</code>
>      */
>     public String save() {
>         LOG.debug("save() Called");
>         setEntity(getDao().save(entity));
>         return SHOW;
>     }
> Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.
> When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):
>             // Check to see if the new model instance is already on the stack
>             for (Object item : root) {
>                 if (item == newModel) {
>                     needsRefresh = false;
>                 }
>             }
> the test equates to true even though I can see in the debugger that the two objects have different object identities.
> Changing line 114 to:
>                 if (item.equals(newModel)) {
> fixes the problem.
> I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.

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


[jira] Updated: (WW-3098) NeedsRefresh not working for ModelDrivenInterceptor and Hibernate

Posted by "Wes Wannemacher (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/struts/browse/WW-3098?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Wes Wannemacher updated WW-3098:
--------------------------------

    Fix Version/s: 2.1.8

I don't see a problem with changing that line of ModelDrivenInterceptor the way you describe, but the problem is that it is XWork code. XWork was just released, so I am going to mark this for 2.1.8 because we are going to run a struts release against xwork 2.1.4, which does not include this fix.

> NeedsRefresh not working for ModelDrivenInterceptor and Hibernate
> -----------------------------------------------------------------
>
>                 Key: WW-3098
>                 URL: https://issues.apache.org/struts/browse/WW-3098
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.1.6
>         Environment: Hibernate
> JPA
> Windows XP
> Tomcat 6 running under Eclipse 3.4
> Java 1.6 with Java 1.5 source compliance
>            Reporter: Peter Kelley
>             Fix For: 2.1.8
>
>
> I have the following configured in struts.xml:
>                 <interceptor-ref name="modelDriven">
>                     <!-- allow actions to change the model during execution so that the view gets a new model. --> 
>                     <param name="refreshModelBeforeResult">true</param>
>                 </interceptor-ref>
> and in my action:
>     /**
>      * Create or update the entity.
>      * 
>      * @return <code>Show</code>
>      */
>     public String save() {
>         LOG.debug("save() Called");
>         setEntity(getDao().save(entity));
>         return SHOW;
>     }
> Where the entity has not previously saved by Hibernate and Hibernate is returning the entity with the id field set.
> When struts gets to the following code in ModelDrivenInterceptor (lines 112-117):
>             // Check to see if the new model instance is already on the stack
>             for (Object item : root) {
>                 if (item == newModel) {
>                     needsRefresh = false;
>                 }
>             }
> the test equates to true even though I can see in the debugger that the two objects have different object identities.
> Changing line 114 to:
>                 if (item.equals(newModel)) {
> fixes the problem.
> I can only think that the cglib enhanced object returned by Hibernate does something weird with == but responds to .equals() correctly.

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