In JBuilder, data is extracted from a server or text file into a data set. Once this data has been "provided" to the data set, you can edit and work with a local copy of the data programmatically or in data-aware controls. To save the data back to the database or text file, you must "resolve" the changes back to the database or export the changes to a text file. The different options for resolving the changes back to the database are discussed in Saving changes back to your data source, and the options for exporting data to a text file are discussed in Exporting data.
In a master-detail relationship, at least two sets of data (database tables and/or text data files in any combination) are being provided to at least two data sets. In general, there are three ways you can resolve changes in a master-detail relationship:
If both data sets are QueryDataSets, you can save changes in both the master and the detail tables using the saveChanges(DataSet[]) method of the Database rather than the saveChanges() method for each data set. Using a simple call to the Database.saveChanges() method keeps the data sets in sync and commits all data in one transaction. Using separate calls to the DataSet.saveChanges() method does not keep the data sets in sync and commits the data in separate transactions. See Resolving master-detail data sets to a JDBC data source below for more information.
If both data sets are QueryDataSets, you can use a separate NavigatorControl for each data set or use a single navigator for both data sets. See Displaying or hiding navigator buttons at run time for information on using a single navigator for both data sets.
Warning: When two NavigatorControls are used, its Save button will only save changes to the data set it is bound to with the NavigatorControl's dataSet property. It is possible to save a master without saving the details, or vice versa, with this system.
See also:
Saving changes back to your data source
Because a master-detail relationship by definition includes at least two sets of data, the simplest way to resolve data back to the data source is to use the saveChanges() method of the Database component (assuming that QueryDataSets are used).
Executing the Database.saveChanges() method causes all of the inserts, deletes, and updates made to the data sets to be saved to the JDBC data source in a single transaction, by default. When the masterLink property has been used to establish a master-detail relationship between two data sets, changes across the related data sets are saved in the following sequence: