How to add new IMendixObject instances to a List<IMendixObject

0
Having a proxy Entity1 with 8 attributes. Want to add new instances of a IMendixObject (with identical attributes) to a List<imendixobject> type list. When I use: while (res.next()) { myfirstmodule.proxies.Entity1 entity1 = null; //entity1 = myfirstmodule.proxies.Entity1.create(getContext()); entity1.setAttribute1(getContext(), res.getInt(1)); entity1.setAttribute2(getContext(),res.getString(2) + "ttt"); entity1.setAttribute3(getContext(),res.getString(3) + "iii"); entity1.setAttribute8(getContext(),res.getBoolean(8)); mList.add(entity1.getMendixObject()) } Getting a warning “Null pointer access; the variable … can only be null at this location” When using: while (res.next()) { myfirstmodule.proxies.Entity1 entity1 = null; entity1 = myfirstmodule.proxies.Entity1.create(getContext()); entity1.setAttribute1(getContext(), res.getInt(1)); entity1.setAttribute2(getContext(),res.getString(2) + "ttt"); entity1.setAttribute3(getContext(),res.getString(3) + "iii"); entity1.setAttribute8(getContext(),res.getBoolean(8)); mList.add(entity1.getMendixObject()); } Empty records are created on the DB-level and instances of entity1 are identical. My question: what is the appropriate way to create new instances (having the same attributes as a proxy) to add to a List<imendixobject> without trouble?
asked
1 answers
0

I think empty records are in your db (instead of non-empty) because you didn't commit anything yet.

So adding entity1.commit(); would result in having the values in your DB.

I don't understand the context of your process: why do you put these objects in a list? What are you trying to achieve?

answered