public Class[] getPkClass() throws ManagerException {
Configuration cfg = hibernateUtil.getConfiguration();
PersistentClass pclass = cfg.getClassMapping(modelClass.getName());
if (pclass == null) {
throw new ManagerException("Unable to find class : "
+ modelClass.toString());
}
Property componentProperty = pclass.getIdentifierProperty();
if (componentProperty == null) {
Component component = pclass.getIdentifierMapper();
if (component == null) {
throw new ManagerException("Unable to get pk mapping");
}
if (log.isDebugEnabled()) log.debug(String.format("Found %d keys for model %s", component.getPropertySpan(), modelClass.getName()));
Class<?>[] classArray = new Class[component.getColumnSpan()];
Iterator<Property> ite = component.getPropertyIterator();
int i = 0;
while (ite.hasNext()) {
Property p = ite.next();
if (log.isDebugEnabled()) log.debug("property name: " + p.getName());
classArray[i++] = p.getType().getReturnedClass();
}
return classArray;
} else {
Value value = componentProperty.getValue();
if (value == null)
throw new ManagerException("Component value is null");
else {
if (log.isDebugEnabled()) log.debug(String.format("Found simple key for model %s '%s'",
modelClass.getName(), value.getType()
.getReturnedClass()));
return new Class[] { value.getType().getReturnedClass() };