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
          Deprecated. This has been renamed as foreignFieldName() to make it more consistent to how it works.
 String foreignFieldName
          Name of the _field_ (not the column name) in the class that the collection is holding that corresponds to the collection.
 int maxEagerForeignCollectionLevel
          Deprecated. Should use maxEagerLevel()
 int maxEagerLevel
          Set this to be the number of times to expand an eager foreign collection's foreign collection.
 boolean orderAscending
          If an order column has been defined with orderColumnName(), this sets the order as ascending (true, the default) or descending (false).
 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.

WARNING: By default, if you have eager collections of objects that themselves have eager collections, the inner collection will be created as lazy for performance reasons. If you need change this see the maxEagerLevel() setting below.

Default:
false

maxEagerForeignCollectionLevel

@Deprecated
public abstract int maxEagerForeignCollectionLevel
Deprecated. Should use maxEagerLevel()

Default:
1

maxEagerLevel

public abstract int maxEagerLevel
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:
""

orderAscending

public abstract boolean orderAscending
If an order column has been defined with orderColumnName(), this sets the order as ascending (true, the default) or descending (false).

Default:
true

foreignColumnName

@Deprecated
public abstract String foreignColumnName
Deprecated. This has been renamed as foreignFieldName() to make it more consistent to how it works.

Default:
""

foreignFieldName

public abstract String foreignFieldName
Name of the _field_ (not the column name) 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.

WARNING: Due to some internal complexities, this it field/member name in the class and _not_ the column-name.

Default:
""


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