app/src/main/java/db/juhaku/juhakudb/core/android/transaction/StoreTransactionTemplate.java
/**
     * Store given items to database. All store operations will be cascaded to referenced tables if
     * given items has child entities.
     *
     * @param items {@link Collection} of items to store.
     * @param parent Object parent entity that is being used to make foreign key relation to parent table.
     *
     * @since 1.2.0
     *
     * @hide
     */
Store given items to database. All store operations will be cascaded to referenced tables if
given items has child entities.

@param items  Collection of items to store.
@param parent Object parent entity that is being used to make foreign key relation to parent table.



@hide
Store given items to database . All store operations will be cascaded to referenced tables if given items has child entities . @param items Collection of items to store . @param parent Object parent entity that is being used to make foreign key relation to parent table . @hide
private void store(Collection<T> items, Object parent) {
        for (T item : items) {
            cascadeStoreBefore(item);
            ContentValues values = getConverter().entityToContentValues(item);
            if (parent != null) {
                values.put(resolveReverseJoinColumnName(item.getClass(), parent.getClass()),
                        ReflectionUtils.getIdFieldValue(parent).toString());
            }
            Long id = insertOrReplace(resolveTableName(item.getClass()), values);
            if (id > -1) {
                ReflectionUtils.setFieldValue(ReflectionUtils.findIdField(item.getClass()), item, id);
                cascadeStoreAfter(item);
            } else {
                Log.v(getClass().getName(), "Failed to store item: " + item + " to database!");
            }
        }
    }
private void store ( Collection < T > items , Object parent ) { for ( T item : items ) { cascadeStoreBefore ( item ) ; ContentValues values = getConverter ( ) . entityToContentValues ( item ) ; if ( parent != null ) { values . put ( resolveReverseJoinColumnName ( item . getClass ( ) , parent . getClass ( ) ) , ReflectionUtils . getIdFieldValue ( parent ) . toString ( ) ) ; } Long id = insertOrReplace ( resolveTableName ( item . getClass ( ) ) , values ) ; if ( id > - 1 ) { ReflectionUtils . setFieldValue ( ReflectionUtils . findIdField ( item . getClass ( ) ) , item , id ) ; cascadeStoreAfter ( item ) ; } else { Log . v ( getClass ( ) . getName ( ) , "Failed to store item: " + item + " to database!" ) ; } } }
Store given items to database.
Store given items to database .
// If parent is specified add parent id to content values as it references to child. // If storing was successful populate object with the database row id. // Some general logging if storing fails.