Note that there are some explanatory texts on larger screens.

plurals
  1. POperformace issue with the code ,exponential working
    text
    copied!<p>I have two lists of type object with data , the first one is principal entity and the second is dependent entity. In addition I have key table that relate between the principal and depended entity objects. In the first for statement I get one instance of type object and then I go and loop on every instance of the second entity and trying to find Match between them (i think exponential problem…) ,if match is find update the principal entity with the reference object . </p> <p>The following code is <strong>working</strong> but I check it from performance perspective and it's not working in efficient way.</p> <p>Do you have an idea/tips how to improve this code from perforce aspect.</p> <p>In the JVM monitor I found that <code>EntityDataCreator.getInstanceValue</code> have a problem.</p> <p><strong>This is the method start</strong></p> <pre><code>// start with the principal entity for (Object principalEntityInstance : principalEntityInstances) { List&lt;Object&gt; genObject = null; Object refObject = createRefObj(dependentMultiplicity); // check entries in dependent entity for (Object dependentEntityInstance : toEntityInstances) { boolean matches = true; for (String[] prop : propertiesMappings) { // Get properties related keys String fromProp = prop[0]; String toProp = prop[1]; Object fromValue = EntityDataCreator.getInstanceValue(fromProp, principalEntityInstance); Object toValue = EntityDataCreator.getInstanceValue(toProp, dependentEntityInstance); if (fromValue != null &amp;&amp; toValue != null) { if (!fromValue.equals(toValue)) { matches = false; break; } } } if (matches) { // all properties match if (refObject instanceof List) { genObject = (List&lt;Object&gt;) refObject; genObject.add(dependentEntityInstance); refObject = genObject; } else { refObject = dependentEntityInstance; break; } } } if (refObject != null) { EntityDataCreator.createMemberValue(principalEntityInstance, navigationPropName, refObject); } } public static Object getInstanceValue(String Property, Object EntityInstance) throws NoSuchFieldException, IllegalAccessException { Class&lt;? extends Object&gt; EntityObj = EntityInstance.getClass(); Field Field = EntityObj.getDeclaredField(Property); Field.setAccessible(true); Object Value = Field.get(EntityInstance); Field.setAccessible(false); return Value; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload