Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
@Retention(CLASS) @Target({FIELD})
public @interface ElementCollection
Mapping for an owned collection of scalar values.
Methods
public abstract FetchType fetch() default FetchType.LAZY | Controls relationship initialization. |
public abstract String column() default "element_value" | Names the scalar value column in the collection table. |
public abstract String joinColumn() default "" | Names the column that holds the owner’s id in the collection table. |
public abstract String type() default "" | The SQL type of the value column, written into CREATE TABLE as it is, like Column.type – for example LONGTEXT – and validated against the existing column the same way. |
public abstract String positionColumn() default "element_position" | Names the column that stores each element’s position, which keys the table together with the owner and keeps a List’s order and duplicates. |
Method details
fetch
public abstract FetchType fetch() default FetchType.LAZYControls relationship initialization.
Returns
fetch policy; EAGER for to-one and LAZY for collections by default
column
public abstract String column() default "element_value"Names the scalar value column in the collection table.
Returns
column name; element_value by default
joinColumn
public abstract String joinColumn() default ""Names the column that holds the owner’s id in the collection table.
Empty keeps
JoinTable.joinColumn when that is set and owner_id
otherwise; naming the column in both places is a build error.Returns
owner column name; empty for the default
type
public abstract String type() default ""The SQL type of the value column, written into
CREATE TABLE as it
is, like Column.type – for example LONGTEXT – and validated against
the existing column the same way.Returns
SQL type; empty for the dialect’s type for the element class
positionColumn
public abstract String positionColumn() default "element_position"Names the column that stores each element’s position, which keys the table together with the owner and keeps a List’s order and duplicates.
An empty name maps a Set to a table with no position column, keyed by
the owner and the value – the layout JPA providers create, so a table
one of them made can be adopted as it is. Such a Set cannot hold null,
and a text value is limited to 255 characters, like any text key.
Returns
column name; element_position by default, empty for none