ahmetalpbalkan/orman — Issue #41: java.lang.NullPointerException
Author: ragunathjawahar
Created: 2012-01-07 01:48:53+00:00
State: open

Uncaught handler: thread main exiting due to uncaught exception
java.lang.NullPointerException
at org.orman.mapper.F.formatField(F.java:38)
at org.orman.mapper.F.formatField(F.java:28)
at org.orman.mapper.C.eq(C.java:18)
at org.orman.mapper.EntityList.refreshList(EntityList.java:115)
at org.orman.mapper.EntityList.lazyLoadIfNeeded(EntityList.java:77)
at org.orman.mapper.EntityList.add(EntityList.java:128)
at com.package.name.ClassName$2.onClick(ClassName.java:126)
at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
at dalvik.system.NativeStart.main(Native Method)

The latest nightly build from the downloads section and the source code has the same problem, I found that the **fieldName** contains the **generatedFieldName** instead of the **fieldName** which returns **null** for **Field** always. I've used a temporary workaround (F.java) which fixed this issue.

```java
public static Field getField(Entity e, String fieldName) {
for (Field f : e.getFields())
if (f.getOriginalName().equals(fieldName) ||
f.getGeneratedName().equals(fieldName))
return f;
return null;
}
```