Saving changes in a master-detail relationship

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:

See also:
Saving changes back to your data source

Resolving master-detail data sets to a JDBC 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:

  1. Deletes
  2. Updates
  3. Inserts
For deletes and updates, the detail data set is processed first. For inserts, the master data set is processed first.