MCPcopy Create free account
hub / github.com/androrm/androrm / saveO2MToDatabase

Method saveO2MToDatabase

src/src/com/orm/androrm/Model.java:618–639  ·  view source on GitHub ↗
(
			
			Context context, 
			Object 	field
			
	)

Source from the content-addressed store, hash-verified

616 }
617
618 @SuppressWarnings("unchecked")
619 private <O extends Model, T extends Model> void saveO2MToDatabase(
620
621 Context context,
622 Object field
623
624 ) throws NoSuchFieldException {
625
626 OneToManyField<T, ?> om = (OneToManyField<T, ?>) field;
627 List<? extends Model> targets = om.getCachedValues();
628
629 for(Model target: targets) {
630 /*
631 * Only save the target, if it has already been saved once to the database.
632 * Otherwise we could save objects, that shouldn't be saved.
633 */
634 if(target.getId() != 0) {
635 setBackLink((T) this, (Class<T>) getClass(), (O) target, (Class<O>) target.getClass());
636 target.save(context);
637 }
638 }
639 }
640
641 /**
642 * Override this method in order to roll-out migrations

Callers 1

persistRelationsMethod · 0.95

Calls 4

setBackLinkMethod · 0.95
getIdMethod · 0.80
saveMethod · 0.80
getCachedValuesMethod · 0.65

Tested by

no test coverage detected