I hope they are well, I have a query to do and it is that I am automating the ups and downs, in fact they work only that they do not walk with the inheritances:
ParamBuilder.java
private LinkedList<Object>loadMethods(IPersistente ip) throws Exception{
LinkedList<Method> m = new LinkedList();
// my problem is in the getDeclaredMethods() that I use it to get me the enter code here get of the created class but not those of the superclass.
for(Method campo : ip.getClass().getDeclaredMethods()){
if (campo.getName().startsWith("get") && !campo.getName().startsWith("getClass")) {
Method metodo = campo;
if(metodo.getParameterCount() == 0) {
if(metodo.isAnnotationPresent(Sort.class)){
m.add(metodo);
}
}
}
}
if(ip instanceof IDependiente && !ip.check()){
Collections.sort(m, new SortDesc());
} else {
Collections.sort(m, new SortAsc());
}
return load(ip, m);
}
In UserModel I tried to use casting but it did not work, and so I have the save of it:
@Override
public void save(IPersistente row) throws Exception {
if(row.getId() == 0){
System.out.println(this.sp.insert());
// I do not get the get of the user class, I tried to use downcasting but it did not work.
this.sp.getBD().conmand(this.sp.insert(), this.pm.getParam(row));
row.setId(this.maxId());
} else {
System.out.println(this.sp.update());
this.sp.getBD().conmand(this.sp.update(), this.pm.getParam(row));
}
if(row instanceof Comprador){
Comprador c = (Comprador) row;
new CompradorModel(this.ip).save(c);
} else if(row instanceof Subastador){
Subastador s = (Subastador) row;
new SubastadorModel(this.ip).save(s);
} else {
Administrador a = (Administrador) row;
new AdministradorModel(this.ip).save(a);
}
}
Let's say I'm new using Reflections, Metadata and Annotations in Java, I have not been around for weeks.
I await your answers, which I will be grateful for.
regards
Aucun commentaire:
Enregistrer un commentaire