-
Notifications
You must be signed in to change notification settings - Fork 8
Updating Collections
Moo will do updates on collections and maps, including matching objects, adding and removing.
In order to update the objects in the destination based on the objects in the source collection, Moo needs to decide which objects correspond to each other. This is of greater import if swapping attribute values might have some consequence, like dirty-checking persistent objects to decide if they should be written to the database.
If you don't intervene, Moo will use iteration order for sets, iteration/index order for lists and keys to match objects across maps. If you'd prefer to intervene, you can identify the matcher to be used by setting the matcher class on the CollectionProperty
annotation.
If an object exists in the source collection but has no match in the destination, moo will translate the source object and add it to to the destination object. Of course, object matching plays a role in deciding whether or not an object can be found in the destination collection.
Because Java collections don't know much about their expected contents due to type erasure of generics, you'll have to specify the item type to which you expect any translations to be performed.
If an object exists in the destination collection but is not matched by an object in the source collection, Moo will remove it from the destination during the update. If you want Moo to avoid doing removals, you can configure it to do so by setting removeOrphans=false
on CollectionProperty
.
- Five Minute Introduction
- Getting Moo
- Translating Object Properties
- Translating Collection Properties
- Translating Map Properties
- Source Expressions
- Access Modes
- Translating to Value Types
- Extensions
- External Objects in Translation
- Ignoring Properties
- Updating Collections
- Translation Target Factories
- Nested Updates
- Optional and Required Properties
- Order of Property Translation
- Constructors
- Lookup on Update
- Caching
Releases
Background