com.j256.ormlite.field
Annotation Type ForeignCollectionField


@Target(value=FIELD)
@Retention(value=RUNTIME)
public @interface ForeignCollectionField

Annotation that identifies a ForeignCollection field in a class that corresponds to objects in a foreign table that match the foreign-id of the current class.

 @ForeignCollection(id = true)
 private ForeignCollection<Order> orders;
 

Author:
graywatson

Optional Element Summary
 String columnName
          The name of the column.
 boolean eager
          Set to true if the collection is a an eager collection where all of the results should be retrieved when the parent object is retrieved.
 String foreignColumnName
          Name of the column in the class that the collection is holding that corresponds to the collection.
 int maxEagerForeignCollectionLevel
          Set this to be the number of times to expand an eager foreign collection's foreign collection.
 String orderColumnName
          The name of the column in the object that we should order by.
 

eager

public abstract boolean eager
Set to true if the collection is a an eager collection where all of the results should be retrieved when the parent object is retrieved. Default is false (lazy) when the results will not be retrieved until you ask for the iterator from the collection.

NOTE: If this is false (i.e. we have a lazy collection) then a connection is held open to the database as you iterate through the collection. This means that you need to make sure it is closed when you finish. See LazyForeignCollection.iterator() for more information.

Default:
false

maxEagerForeignCollectionLevel

public abstract int maxEagerForeignCollectionLevel
Set this to be the number of times to expand an eager foreign collection's foreign collection. If you query for A and it has an eager foreign-collection of field B which has an eager foreign-collection of field C ..., then a lot of database operations are going to happen whenever you query for A. By default this value is 1 meaning that if you query for A, the collection of B will be eager fetched but each of the B objects will have a lazy collection instead of an eager collection of C. It should be increased only if you know what you are doing.

Default:
1

columnName

public abstract String columnName
The name of the column. This is only used when you want to match the string passed to Dao.getEmptyForeignCollection(String) or when you want to specify it in QueryBuilder.selectColumns(String...).

Default:
""

orderColumnName

public abstract String orderColumnName
The name of the column in the object that we should order by.

Default:
""

foreignColumnName

public abstract String foreignColumnName
Name of the column in the class that the collection is holding that corresponds to the collection. This is needed if there are two foreign fields in the class in the collection (such as a tree structure) and you want to identify which column you want in this collection.

Default:
""


This content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.