if (pks.length > 0) {
Class<?> pkType = pks[0].getDeclaredType();
try {
// Check for basic types, cast provided object to expected type. Catch CCE for invalid input
if (pkType.equals(Byte.class) || pkType.equals(byte.class))
return new ByteId(cls, (Byte) oid);
if (pkType.equals(Character.class) || pkType.equals(char.class))
return new CharId(cls, (Character) oid);
if (pkType.equals(Double.class) || pkType.equals(double.class))
return new DoubleId(cls, (Double) oid);
if (pkType.equals(Float.class) || pkType.equals(float.class))