public interface DataSourceRelations foreignKey property. Declaring foreign key relations between dataSources enables multiple sophisticated and automatic behaviors. The default editor for Many-to-one relation fields is a SelectItem, allowing the user to select a new value for the field from the options available in the related dataSource.
The default editor for one-to-many relation fields is a MultiPickerItem, allowing the user to select a new set of values for the field from the options available in the related dataSource.
As with one-to-many relation fields, many-to-many fields will show a MultiPickerItem as the default editing interface.
includeFrom mechanism. includeFrom fields will be automatically included from the parent dataSource whenever data is fetched from the child dataSource Smart GWT does not support updating the "parent" dataSource fields across a many-to-one relation. You can update the relation itself (by updating the foreignKey), but any fields that are included from the parent dataSource must be updated with a separate update operation on the parent dataSource
Many-to-one relations are supported for all dataSource types, both the built-in server dataSource types and clientOnly dataSources. They are also supported without any extra effort with your own custom dataSource implementations on the server
foreignKey to the other dataSource and the multiple property on the field. The way this idea of multiple related records is handled varies according to the dataSource type:
JPA and Hibernate dataSources, in keeping with the underlying ORM ethos, take an object-based approach: the related records are returned as a list of full-formed record objects, and it is possible to update across the relation simply by modifying the properties of the related record(s) and then updating the base record. See the JPA and Hibernate Relations article for more detail of JPA/Hibernate and relationsSQL dataSources take a relational approach: the related records are not returned directly, but rather a list of the key values required to fetch the related records from the related dataSource. Therefore, an additional fetch is needed to fetch the actual related data. Updates are likewise relational: your code provides the "new" list of related keys, and Smart GWT modifies the foreignKey values accordingly; no "child" records are created, updated or deleted in this process, the child records are assumed to exist, and here we are just updating the relational information to link to them. Updating the actual data on the child record(s) is done with separate update operation(s) on the child dataSourceforeignKey to the related dataSource, via the "join" dataSource, and the multiple property, on the foreignKey field of one of the dataSources in the many-to-many relation. For example, declaring the foreignKey to Teams on the Employee dataSource (note the dots indicating that the relation path to use is EmployeeTeams->Teams):
<field name="teams" multiple="true" foreignKey="EmployeeTeams.Teams.teamId" />
The way this idea of multiple related records is handled is different according to dataSource type, similar to one-to-many relations:DataSourceField.foreignKey, DataSourceField.multiple, JpaHibernateRelations, JoinType, DataSource.relatedTableAlias, DataSourceField.getPrimaryKey(), DataSourceField.getForeignKey(), DataSourceField.getChildrenProperty(), DataSourceField.getRootValue(), DataSourceField.includeFrom, DataSourceField.includeVia, DataSourceField.relatedTableAlias, DataSourceField.otherFKs, DataSourceField.getDisplayField(), DataSourceField.getForeignDisplayField(), DataSourceField.joinType, DataSource.getChildrenField()