Community
Participate
Working Groups
Build Identifier: 2.2 revision 8831 - 01/14/2011 03:10 AM When defining "AttributeTransformer"/"Method attribute transformer" access to field value is through record.get(<field_name>). <field_name> can be DatabaseRecord or String (-this is used usually) record.get(<String_field_name>) - created "lookup DatabaseField" with index=-1 it means that AbstractRecord must search every time for proper field index 'Vector.indexOf' --- Sample transformer public class TimeTransformer extends AttributeTransformerAdapter { @Override public Object buildAttributeValue(final Record record, final Object object, final Session session) { Long actionS = (Long) record.get("ACTION_S"); // new 'lookup' DatabaseField is created with index -1 - forces call AbstractRecord.fields.indexOf Long actionF = (Long) record.get("ACTION_F"); // reused previous 'lookup' database field index again set to -1 - forces call AbstractRecord.fields.indexOf } } There is called AbstractRecord.fields.indexOf for every row and every field accessed in in 'buildAttributeValue' -> no optimalisation, Vector.indexOf has O(n) --- Expected behaviour fields.indexOf should be called only once/query no for every row*every_field --- Possible workaround - not sure it its correct - don't know if index of DatabaseField can change between different queries cache locally and reuse DatabaseField in AttributeTransformerAdapter - not possible for method attribute transformer Reproducible: Always
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Calling record.get(String) only has the String so no index, so it will be O(n). This is expected. Can't see any way to get an index when using String lookup. The lookup field will get the index, but this will only help if you only lookup by one field name. If you wish to use an index, you need to cache your DatabaseField. DatabaseField field; // declare as variable in transformer or static in class if using method access record.get(field); // this will assign the index on the first call, so be O(1). Suggesting this be closed.
I can't recommend your suggested workaround to cache DatabaseField. There is no warranty that cached index will be always correct. You can execute full query followed by partial query and then the cached index will be invalid. I'm not 100% sure that EclipseLink has fallback when index is set to wrong field. Please, if you can please let this issue open for Future as Target Milestone.
moving to future as part of 2.3 bug scrub.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink