GithubHelp home page GithubHelp logo

Comments (3)

locnguyenx avatar locnguyenx commented on May 20, 2024

For case 1, after scrutinize the EntityFindBase I find that:

  • if in XMLAction we use entity-find-one without any field-map, then moqui will call .condition(context), then create simpleAndMap with only 1 key. Due to the viewentity PersonAndUserAccount has more than 1 PKs, the oneInternal method will return null.
  • if we use entity-find-one with a field-map. i.e 'partyId', then moqui will call .condition(field, value), then create a pair of singleCondField/singleCondValue. Later on, the oneInternal method will form a whereCondition with this field/value and return result as expected.

I've tried to change the method EntityFind condition(Map<String, Object> fields) to force using singleCondField/singleCondValue instead of simpleAndMap if it has only 1 field:

if (fieldsSize == 1 && noSam && noScf) {
            // just set the singleCondField
            Map.Entry<String, Object> onlyEntry = fields.entrySet().iterator().next()
            singleCondField = (String) onlyEntry.key
            singleCondValue = onlyEntry.value
        } else {
            if (noSam) simpleAndMap = new LinkedHashMap<String, Object>()
            if (!noScf) {
                simpleAndMap.put(singleCondField, singleCondValue)
                singleCondField = (String) null
                singleCondValue = null
            }
            getEntityDef().setFields(fields, simpleAndMap, true, null, null)

            // My Code: use singleCond to avoid checking PKs in .oneInternal()
            if (simpleAndMap?.size() == 1 && noScf) {
                // just set the singleCondField
                Map.Entry<String, Object> onlyEntry = simpleAndMap.entrySet().iterator().next()
                singleCondField = (String) onlyEntry.key
                singleCondValue = onlyEntry.value
                simpleAndMap = null
            }
        }

This fixed the issue that use entity-find-one without any field-map. However, I don't know if this change will have any side-effect or not.

About the case 2, I can't reproduce the issue.

from moqui-framework.

jonesde avatar jonesde commented on May 20, 2024

Would you pull the latest code and try this again? I am unable to reproduce the error.

If I understand correctly this error should be seen by just going to:

http://localhost:8080/apps/hmadmin/User/EditUser?partyId=EX_JOHN_DOE

That screen and the populated form are rendering fine for me now with the single PK for the view-entity entity-find-one. Let me know if there is something different that needs to be done to reproduce this issue.

The EntityFindBase code, and lots of code related to it, has been reviewed and updated quite a bit (mostly for performance/efficiency), and while it is somewhat complex and messy to run faster it should all be working now.

from moqui-framework.

locnguyenx avatar locnguyenx commented on May 20, 2024

This issue not happen with newest code. It has been fixed in commit 2e6eaff.
In this commit, system don't change simpleAndMap in case its size = 1

from moqui-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.