CLASE BD2 23/09/2026 SQL queries recursivos unidad II 1 Introduccion al uso de JPA 2 generico.pdf 2 Introduccion al uso de JPA 2.pdf 3 Introduccion al uso de JPA 2 y swing.pdf Clases Genericas ArrayList arr = new ArrayList(); Cliente c1 = new Cliente(...); Cliente c2 = new Cliente(...); Cliente c3 = new Cliente(...); arr.add(c1); // ... public void add(Object o) arr.add(c2); // UPCASTING Cliente --> Object arr.add(c3); // SEGURO xq todo Cliente IS AN Object ... Cliente c = (Cliente) arr.get(0); // public Object get(int) Cliente d = (Cliente) arr.get(1); // DOWNCASTING Object --> Cliente Cliente e = (Cliente) arr.get(2); // INSEGURO xq no todo Object IS AN Cliente ----x---- framework basado en Object e inseguro -> error runtime public class ArrayList { ... public void add(X o) { .. } public X get(int pos) { .. } } ArrayList ac = new ArrayList(); ac.add(new Cliente(...)); ac.add(new Cliente(...)); ac.add(new Cliente(...)); ac.add(new Producto(...)); // ERROR DE COMPILACION .. Cliente c = ac.get(0); Producto p = ac.get(1); // ERROR DE COMPILACION .. evita errores en runtime Reflection java compilado e interpretado prog.java -> compilar -> prog.class -> interpreta JVM -> runtime en runtime permite que un .class se examine a si mismo u a otro .class es posible guardar METADATA dentro de un .class Clase Class permite inspeccionar el contenido de un .class y buscar anotaciones Annotations es una forma de ingresar METADATA dentro del .class @Entity public class Cliente { ... } JPA=Genericos+Reflection+Anotaciones Utiliza reflection para inspeccionar clases y determinar x ej cuales son entidades que debe persistir Programming by exception ORM Hibernate,JPA JPA 2.0