roscopeco / ormdroid

ORMDroid is a simple ORM persistence framework for your Android applications.
http://roscopeco.github.io/ormdroid/
Apache License 2.0
86 stars 24 forks source link

An ambigous exception on unknown type serialization #10

Closed rothschild86 closed 11 years ago

rothschild86 commented 11 years ago

If there is a Java.util.date property on the entity, "Failed to instantiate model class - does it have a public null constructor?" exception is thrown.

In this case it happened because Entity.load() method swallowed IllegalArgumentExeption and replaced it with ORMDroidException.

catch (Exception e) { throw new ORMDroidException( "Failed to instantiate model class - does it have a public null constructor?", e); }

Perhaps ORMDroidException should at least print e.getClass() for the original exception?

But even then IllegalArgumentExeption does not quite indicate that there was a problem with type serialization. Needs better handling?

On the subject of dates, since util.Date, maybe it is worth serializing it (maybe not)? Azure Mobile Services handles it this way and it works quite well:

https://github.com/WindowsAzure/azure-mobile-services/blob/master/sdk/android/src/sdk/src/com/microsoft/windowsazure/mobileservices/DateSerializer.java

roscopeco commented 11 years ago

Fixed in master. Will make next release.

roscopeco commented 11 years ago

Thanks for the report!

This fix brings in a (minor) API change, in that it removes the default mapping. If your code relies on it you must now set the default mapping manually using TypeMapper#setDefaultMapping.

rothschild86 commented 11 years ago

DateMapper - sweet! :) Lot's of good changes man. Loving it!

On Mon, Jul 1, 2013 at 9:15 PM, Ross Bamford notifications@github.comwrote:

Thanks for the report!

This fix brings in a (minor) API change, in that it removes the default mapping. If your code relies on it you must now set the default mapping manually using TypeMapper#setDefaultMapping.

— Reply to this email directly or view it on GitHubhttps://github.com/roscopeco/ormdroid/issues/10#issuecomment-20321048 .