pojoModel.setAdaptorName("JDBCAdaptor");
//ak: fake dict for possible NPE
pojoModel.setConnectionDictionary(new NSMutableDictionary());
EOModelGroup.defaultGroup().addModel(pojoModel);
}
EOEntity entity = EOModelGroup.defaultGroup().entityNamed(entityName);
/*if (entity != null) {
pojoModel.removeEntity(entity);
entity = null;
}*/
EOClassDescription classDescription;
if (entity == null) {
entity = new EOEntity();
entity.setName(entityName);
keys = (keys == null ? fieldNamesFromClass(clazz) : keys);
for (Enumeration iter = keys.objectEnumerator(); iter.hasMoreElements();) {
String name = (String) iter.nextElement();
EOAttribute attribute = new EOAttribute();
attribute.setName(name);
Method m = methodForName(clazz, name);
if(m != null) {
attribute.setClassName(m.getReturnType().getName());
} else {
Field f = fieldForName(clazz, name);
if(f != null) {
String type = f.getType().getName();
if("boolean".equals(type)) {
type = "java.lang.Boolean";
} else if("int".equals(type)) {
type = "java.lang.Number";
} else if("long".equals(type)) {
type = "java.lang.Number";
} else if("short".equals(type)) {
type = "java.lang.Number";
}
attribute.setClassName(type);
}
}
entity.addAttribute(attribute);
}
classDescription = new EOEntityClassDescription(entity);
NSKeyValueCoding.Utility.takeValueForKey(entity, classDescription, "classDescription");
EOClassDescription.registerClassDescription(classDescription, clazz);
pojoModel.addEntity(entity);