Hello!
I get this error from a deployed bpm process when I try to access the edit screen of an entity:
IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter entityId with expected type of class java.util.UUID from query string select pi from bpm$ProcInstance pi where pi.procDefinition.id = :procDefinition and pi.entityId = :entityId.
This is my entity:
public class Building extends BaseStringIdEntity implements HasUuid {
private static final long serialVersionUID = 8474095780417145277L;
@Column(name = "UUID", nullable = false)
protected UUID uuid;
@Id
@CaseConversion
@NotNull
@Column(name = "BUILDING_ID", nullable = false, unique = true, length = 16)
protected String building_id;
@NotNull
@Column(name = "STATUS", nullable = false)
protected String status = BuildingStatus.ACTIVE.name();
@Override
public void setUuid(UUID uuid) {
this.uuid = uuid;
}
@Override
public UUID getUuid() {
return uuid;
}
@Override
public String getId() {
return this.building_id;
}
@Override
public void setId(String id) {
this.building_id = id;
}
public void setStatus(BuildingStatus status) {
this.status = status == null ? null : status.getId();
}
public BuildingStatus getStatus() {
return status == null ? null : BuildingStatus.fromId(status);
}
}
This is the class from which I call an operation on the entity through a server task declared in the bpm model:
@Component("BuildingHelperBean")
public class BuildingHelper {
@Inject
private Persistence persistence;
public void updateStatus(String entityId, String statusId) {
try (Transaction tx = persistence.getTransaction()) {
Building building = persistence.getEntityManager().find(Building.class, entityId);
if (building != null) {
building.setStatus(BuildingStatus.fromId(statusId));
}
tx.commit();
}
}
}
This is the editor screen controller:
public class BuildingEdit extends AbstractEditor<Building> {
public static final String PROC_CODE = "buildingInspection";
@Inject
private ProcActionsFrame procActionsFrame;
@Override
protected void postInit() {
initProcActionsFrame();
}
private void initProcActionsFrame() {
procActionsFrame.initializer()
.setBeforeStartProcessPredicate(this::commit)
.setAfterStartProcessListener(() -> {
showNotification(getMessage("processStarted"), NotificationType.HUMANIZED);
close(COMMIT_ACTION_ID);
})
.setBeforeCompleteTaskPredicate(this::commit)
.setAfterCompleteTaskListener(() -> {
showNotification(getMessage("taskCompleted"), NotificationType.HUMANIZED);
close(COMMIT_ACTION_ID);
})
.init(PROC_CODE, getItem());
}
}
From a quick glance inside the app log, the error seems to be coming from procActionsFrame.init(PROC_CODE, getItem()).
Inside the init method I found that it requires a Uuid implementation and it calls the getUuid method of the entity so it should not confuse my primary key (which is String) with the uuid.
What is the problem and how to fix it ?
Thanks.