Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdate/Merge SQLite DB table from java objects
    primarykey
    data
    text
    <p>Here a minimal example to describe the issue:</p> <p>Suppose a table is read from a SQLiteDB and store it in a Java Collection object</p> <h2>DB table--->Java Object</h2> <hr> <pre><code>idRecord | Data (table stored at DB) 1 One 2 Two 3 Three 4 Four </code></pre> <p>And through an <strong>sqlite jdbc</strong> library :</p> <p>Map objTable = new HashMap (); //...adding some jdbc stuff, we get a copy of DBTable in objTable</p> <p>Then if <strong>object</strong> is modified, thus being.</p> <pre><code>idRecord | Data (modified table stored at objTable) 2 Two 4 FourModified 5 Five </code></pre> <p><em>(id 1 and 3 were deleted, 2 remain the same, 4 modified, and 5 added)</em></p> <h2>Java Object-->DB table (Here is the question...)</h2> <hr> <p><strong>How to Update/Merge the object table with the DB ?</strong></p> <p>Why I want to merge and not to simple save the object to the table <strong>?</strong></p> <p><em>I think that if the table is large enough then it has no sense in writing all the records if only some of them were modified.</em></p> <ul> <li><p>Delete the whole DBtable and in a (dangerous meanwhile) loop, walk the object to write the new table.</p></li> <li><p>Read the DBtable in a second java obj and then compare both (with some kind of merge alghoritm) and apply the actions (ADD, DELETE, MODIFY) directly to DB. (I would acept recomendation for that comparison alghorithm)</p></li> <li><p><strong>EDIT:</strong> <em>Do not create the Collection in the first place,</em> reading and writing directly from DB, passing queries all the time through JDBC</p></li> <li><p>Other better approach</p></li> </ul> <p>Thanks4Reading</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload