ahmetb / orman

lightweight and minimalist ORM for Java/Android. works with SQLite & MySQL. (not actively maintained)
Other
249 stars 47 forks source link

Enum Fields #44

Closed anotherpit closed 12 years ago

anotherpit commented 12 years ago

Can't reopen issue #17, so have to create a new one.

org.orman.mapper.ReverseMapping is broken as its method map() causes ClassCastException when trying to cast String to Integer: fieldValue = enumConstant[(Integer) fieldValue];.

The whole enum processing should be moved to smartCasting() method and use new Integer(value.toString()) for enums.

ahmetb commented 12 years ago

I have no idea how fieldValue arrived there as String but your solution is better for converting to Integer. I also handled enum field being null that previously logged an error due to NullPointerException redundantly. Updated the jar in Downloads. Thanks!

anotherpit commented 12 years ago

Neither can I figure out why I decided it was String to Integer conversion problem. Anyway, new JAR works like a charm. Thanks.