}
UserIDClassAnalyzer uica = new UserIDClassAnalyzer(logger);
loader.loadJavaClass(isSrcJar, className, _scp.output,false)
.accept(uica, true);
if (uica.fieldNames.isEmpty()) {
throw new SpeedoException("The identifier class '"
+ sc.identity.objectidClass + "' has no public field.");
}
if (sc.getSuperClassName() != null) {
//do nothing, the primary key field are inherited from the ancestor
} else if (pkfields.isEmpty()) {
for(int i=0; i<uica.fieldNames.size(); i++) {
SpeedoField sf = (SpeedoField) sc.fields.get(uica.fieldNames.get(i));
if (sf == null) {
logger.log(BasicLevel.WARN, "The public field '"
+ uica.fieldNames.get(i) + "' of the identifier class "
+ className + "' does not match to any field in the persistent class '"
+ sc.getFQName() +"'.");
continue;
}
if (!sf.type.equals(uica.fieldTypes.get(i))) {
throw new SpeedoException("The field '" + sf.name
+ "' has not the same type in identifier class '"
+ className + "' ("
+ Util.type(Type.getType((String) uica.fieldTypes.get(i)))
+ ") and in the persistent class '" + sc.getFQName()
+ "' (" + Util.type(Type.getType(sf.type)) + ").");
}
sf.primaryKey = true;
}
} else {
//check that the lists are the same
for(int i=0; i<pkfields.size(); i++) {
if (!uica.fieldNames.contains(((SpeedoField) pkfields.get(i)).name)) {
logger.log(BasicLevel.ERROR, "uica.fieldNames:\n" + uica.fieldNames);
logger.log(BasicLevel.ERROR, "pkfields:\n" + pkfields);
throw new SpeedoException("The field '" + pkfields.get(i)
+ "' is marked primary-key=true whereas it is not "
+ "defined in the identifier class '" + className
+ "' associated to the persistent class '"
+ sc.getFQName() + "'.");
}