1. Can I directly use the foreign key id?
# An error occurs when declaring a foreign key object and creating a table with the same common field, and when querying data.
# Http://stackoverflow.com/questions/18988750/ormlite-android-setting-foreign-key-fields-directly
# Two classes are declared to process objects and IDs respectively.
2. The object itself has CRUD, BaseDaoEnabled
The instance method of the object has the corresponding crud
As long as there is inheritance.
If it is a new object, setDao is required to specify the corresponding dao.
If you use dao for the query, the query is automatically set, and the update operation is performed directly.
3, http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_2.html#foreignAutoRefresh
Similar to eager, it is one-to-one, one-to-Multiple-side. I don't know if this is correct.
4. lazyload eager load
4.1 Configuration operations
@ ForeignCollectionField (eager = true)
When querying, you can directly check the association and set it to the attribute.
4.2 manually specify
# Http://stackoverflow.com/questions/7301418/ormlite-inner-join-on-three-tables
Http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_3.html#Join-Queries
QueryBuilder. join can be used.
Note: add conditional values to join, and then traverse the entire table.
4.3 eagerload does not only show the association of one object, and it seems that n + 1 queries exist. It seems that only join is used to solve this problem.
5. raw query
Http://ormlite.com/javadoc/ormlite-core/doc-files/ormlite_2.html#Raw-Queries
GenericRawResults <String []> result returns an object.
Result. getColumnNames () # array of column
Result. getResults () List <String []> each string [] corresponds to columns