Ormlite learning notes in java

Source: Internet
Author: User


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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.