I load a Entity with LoadEntity function, and not all properties where set of the object

when I set queryoptimization=0 it was fixed

Submitted by chris melman on 17 December 2012 at 15:56

On 17 December 2012 at 15:56 chris melman tagged queryoptimization

On 17 December 2012 at 16:08 Elmer van Chastelet commented:

Let’s transform this succeed test into a web test

…/test/succeed/load-entity.app


On 18 December 2012 at 10:18 Christoffer Gersen commented:

Do you have an example, because when I create a simple page that uses loadEntity, then everything seems to work fine, even with optimizations enabled.


On 18 December 2012 at 10:54 chris melman commented:

the example is generated code so it might be not the best readable code

service webservice_generated_syncProject ( )
{
var json := JSONObject() ;
var errors := JSONArray() ;
var request := JSONArray(readRequestBody()) ;
var result := JSONArray() ;
for ( count : Int from 0 to request.length() )
{
  var tl := ( loadEntity("Project", request.getJSONObject(count).getString("id").parseUUID()) as Project ) ;
  var timestamp := request.getJSONObject(count).getLong("lastSynced") ;
  for ( ent : Project in getAllProjectForProject(tl) where timestamp == 0 || ent.modified != null && ent.modified.getTime() > timestamp )
    {
      result.put(addDirtyFalse(ent.toJSON()));
    }
}
json.put("errors", errors);
json.put("result", result);
return json;
}


function toJSON ( ) : JSONObject
{
var object := JSONObject() ;
if ( this.test13 == null )
{
  object.put("test13", ( null as JSONObject ));
}
else
{
  var arraytest13 := JSONArray() ;
  for ( j_37337 : Project in this.test13 )
    {
      arraytest13.put(makeJSONObjectFromEntityRef(j_37337));
    }
  object.put("test13", arraytest13);
}
if ( this.test12 == null )
{
  object.put("test12", ( null as JSONObject ));
}
else
{
  object.put("test12", makeJSONObjectFromEntityRef(this.test12));
}
if ( this.test11 == null )
{
  object.put("test11", ( null as JSONObject ));
}
else
{
  object.put("test11", this.test11.getTime() / 1000L);
}
if ( this.test10 == null )
{
  object.put("test10", ( null as JSONObject ));
}
else
{
  object.put("test10", this.test10.getTime() / 1000L);
}
if ( this.test9 == null )
{
  object.put("test9", ( null as JSONObject ));
}
else
{
  object.put("test9", this.test9.getTime() / 1000L);
}
if ( this.test8 == null )
{
  object.put("test8", ( null as JSONObject ));
}
else
{
  object.put("test8", this.test8);
}
if ( this.test7 == null )
{
  object.put("test7", ( null as JSONObject ));
}
else
{
  object.put("test7", this.test7);
}
if ( this.test6 == null )
{
  object.put("test6", ( null as JSONObject ));
}
else
{
  object.put("test6", this.test6);
}
if ( this.test4 == null )
{
  object.put("test4", ( null as JSONObject ));
}
else
{
  object.put("test4", this.test4);
}
if ( this.test3 == null )
{
  object.put("test3", ( null as JSONObject ));
}
else
{
  object.put("test3", this.test3);
}
if ( this.test2 == null )
{
  object.put("test2", ( null as JSONObject ));
}
else
{
  object.put("test2", this.test2.format());
}
if ( this.test1 == null )
{
  object.put("test1", ( null as JSONObject ));
}
else
{
  object.put("test1", this.test1);
}
if ( this.name == null )
{
  object.put("name", ( null as JSONObject ));
}
else
{
  object.put("name", this.name);
}
if ( this.description == null )
{
  object.put("description", ( null as JSONObject ));
}
else
{
  object.put("description", this.description.format());
}
if ( this.url == null )
{
  object.put("url", ( null as JSONObject ));
}
else
{
  object.put("url", this.url);
}
if ( this.issues == null )
{
  object.put("issues", ( null as JSONObject ));
}
else
{
  var arrayissues := JSONArray() ;
  for ( k_37337 : Issue in this.issues )
    {
      arrayissues.put(makeJSONObjectFromEntityRef(k_37337));
    }
  object.put("issues", arrayissues);
}
if ( this.members == null )
{
  object.put("members", ( null as JSONObject ));
}
else
{
  var arraymembers := JSONArray() ;
  for ( l_37337 : User in this.members )
    {
      arraymembers.put(makeJSONObjectFromEntityRef(l_37337));
    }
  object.put("members", arraymembers);
}
if ( this.memberRequests == null )
{
  object.put("memberRequests", ( null as JSONObject ));
}
else
{
  var arraymemberRequests := JSONArray() ;
  for ( m_37337 : User in this.memberRequests )
    {
      arraymemberRequests.put(makeJSONObjectFromEntityRef(m_37337));
    }
  object.put("memberRequests", arraymemberRequests);
}
if ( this.followers == null )
{
  object.put("followers", ( null as JSONObject ));
}
else
{
  var arrayfollowers := JSONArray() ;
  for ( n_37337 : User in this.followers )
    {
      arrayfollowers.put(makeJSONObjectFromEntityRef(n_37337));
    }
  object.put("followers", arrayfollowers);
}
if ( this.private == null )
{
  object.put("private", ( null as JSONObject ));
}
else
{
  object.put("private", this.private);
}
if ( this.email == null )
{
  object.put("email", ( null as JSONObject ));
}
else
{
  object.put("email", this.email);
}
if ( this.version == null )
{
  object.put("version", ( null as JSONObject ));
}
else
{
  object.put("version", this.version);
}
if ( this.id == null )
{
  object.put("id", ( null as JSONObject ));
}
else
{
  object.put("id", this.id);
}
return object;
}

this is the biggest part of the code where it happens


On 18 December 2012 at 12:15 chris melman commented:

updated to newest version fixed it so somehow it was fixed inbetween already


On 18 December 2012 at 12:15 chris melman closed this issue.

On 17 June 2013 at 14:14 Elmer van Chastelet tagged query-optimization

On 17 June 2013 at 14:14 Elmer van Chastelet removed tag queryoptimization

Log in to post comments