Are ID fields inherited in ORMLite?
Let's say I have the following class:
public abstract class AHuman
{
@DatabaseField(id = true)
protected String login;
}
And the following two classes extend it:
@DatabaseTable(daoClass = UserDAO.class)
public class User extends AHuman
{
User() {}
@ForeignCollectionField
private ForeignCollection<Person> friends;
}
@DatabaseTable(daoClass = PersonDAO.class)
public class Person extends AHuman
{
Person() {}
}
When I compile and run this on my Android device, I get the following errors:
java.sql.SQLException: Could not call the constructor in class class
com.j256.ormlite.table.CustomDaoTest$A_DaoImpl
at com.j256.ormlite.misc.SqlExceptionUtil.create(SqlExceptionUtil.java:22)
...
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
Caused by: java.lang.IllegalArgumentException: Foreign field class
>>>> com.j256.ormlite.table.CustomDaoTest$B does not have id field <<<<<<
at com.j256.ormlite.field.FieldType.configDaoInformation(FieldType.java:332)
This error comes from ForeignCollection<Person>
being declared in the class User
.
Apparently, based on the next question here , this is due to the Person class not having an id field declared in.
But aren't the "id" fields inherited from the abtract class also included in the Child object?
+3
source to share