private void assignUuidToNewInstances(Collection commitInstances, Collection newInstanceIds) { for (Object id : newInstanceIds) { for (Object instance : commitInstances) { Entity entity = (Entity) instance; if (entity instanceof HasUuid) { String entityFullId = EntityLoadInfo.create(entity).toString(); if (entityFullId.equals(id) && ((HasUuid) entity).getUuid() == null) { ((HasUuid) entity).setUuid(UuidProvider.createUuid()); } } } } }
IdProxy(BaseDbGeneratedIdEntity<T> entity) { Preconditions.checkNotNullArgument(entity, "entity is null"); this.entity = entity; if (entity instanceof HasUuid) { this.uuid = ((HasUuid) entity).getUuid(); if (this.uuid == null) throw new IllegalStateException("Entity " + entity.getClass() + " implements HasUuid but its instance has no UUID assigned"); this.hashCode = this.uuid.hashCode(); } else { this.uuid = UuidProvider.createUuid(); this.hashCode = 0; // trade-off, see com.haulmont.cuba.primary_keys.IdentityTest.testEquality } }
protected void assignUuid(Entity entity) { if (entity instanceof HasUuid) { ((HasUuid) entity).setUuid(UuidProvider.createUuid()); } }
/** * @param entity entity * @return entity id to store in database */ public Object getReferenceId(Entity entity) { if (entity instanceof HasUuid) { return ((HasUuid) entity).getUuid(); } Object entityId = entity.getId(); if (entityId instanceof IdProxy) { return ((IdProxy) entityId).get(); } return entity.getId(); }
((BaseIntIdentityIdEntity) entity).setId(IdProxy.of(Integer.valueOf(string))); } else if (entity instanceof HasUuid) { ((HasUuid) entity).setUuid(UUID.fromString(string));
Object entityId = e.getId(); if (metadata.getTools().hasCompositePrimaryKey(metaClass) && HasUuid.class.isAssignableFrom(metaClass.getJavaClass())) { entityId = ((HasUuid) e).getUuid();