I have the following tables -
@DatabaseTable(tableName=\"b\", daoClass=B_DaoImpl.class)
public class B {
@DatabaseField
public String b1 ;
public
I suspect that there is cause message you are missing at the end of your exception stack trace. For example, if I duplicate your example above I get:
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)
...
Because A
has a foreign field of class B
, then B
needs to have an id field. Identity fields are required for foreign fields.
I'm sure A
and B
are simplistic versions of your classes so if you post more of the exception including all of the cause information, I'll edit my answer appropriately.