Saving new Entities + Updating Existing Ones using UUID only

I currently have a situation where I am passing entities with a pre-set UUID only, and I would like the following to happen:

  1. If the uuid does not exist save the entity

  2. If the uuid exists, then update the existing entity in the database with the data passed from the new object.

Is there any example code that shows this kind of functionality? Should I use metadata deploy to handle this?

I haven’t run the code, but something like this should work:

Location existingLocation = locationService.getLocationByUuid(location.getUuid());
if (existingLocation== null) {
} else {
  //evict existing location from Hibernate session as we will attempt to overwrite it

This is what Metadata Deploy is for, yes.

@raff How would this be done via Metadata deploy?

@ssmusoke, the recipe for “installing” metadata is well described at