Object expected = meta.getObjectIdType();
try {
switch (meta.getIdentityType()) {
case ClassMetaData.ID_DATASTORE:
if (oid instanceof String && ((String) oid).startsWith(StateManagerId.STRING_PREFIX))
return new StateManagerId((String) oid);
return new Id(cls, ((Number) oid).longValue());
case ClassMetaData.ID_APPLICATION:
if (ImplHelper.isAssignable(meta.getObjectIdType(), oid.getClass())) {
if (!meta.isOpenJPAIdentity() && meta.isObjectIdTypeShared())
return new ObjectId(cls, oid);