Package javax.persistence

Examples of javax.persistence.Id


        }

        if (isId) {
            flags = Flag.Id.setTrue(flags);
        } else {
            Id id = field.getAnnotation(Id.class);
            if (id != null) {
                flags = Flag.Id.setTrue(flags);
            }
        }
        column = field.getAnnotation(Column.class);
View Full Code Here


   
  public static String searchFieldsForPK(Class<?> aType) {
    String pkName = null;
    Field[] fields = aType.getDeclaredFields();
    for (Field field : fields) {
      Id id = field.getAnnotation(Id.class);
      if (id != null) {
        pkName = field.getName();
        break;
      }
    }
View Full Code Here

 
  public static String searchMethodsForPK(Class<?> aType) {
    String pkName = null;
    Method[] methods = aType.getDeclaredMethods();
    for (Method method : methods) {
      Id id = method.getAnnotation(Id.class);
      if (id != null) {
        pkName = method.getName().substring(4);
        pkName = method.getName().substring(3, 4).toLowerCase()
            + pkName;
        break;
View Full Code Here

        try{
            do {
                Field[] fields = varClass.getDeclaredFields();
                for (int i = 0; i < fields.length && idValue == null; i++) {
                    Field field = fields[i];
                    Id id = field.getAnnotation(Id.class);
                    if (id != null) {
                        try {
                            idValue = callIdMethod(o, "get"
                                    + Character.toUpperCase(field.getName().charAt(0))
                                    + field.getName().substring(1));
                        } catch (NoSuchMethodException e) {
                            idValue = (Serializable) field.get(o);
                        }
                    }
                }
            } while ((varClass = varClass.getSuperclass()) != null && idValue == null);
            if (idValue == null) {
                varClass = o.getClass();
                do {
                    Method[] methods = varClass.getMethods();
                    for (int i = 0; i < methods.length && idValue == null; i++) {
                        Method method = methods[i];
                        Id id = method.getAnnotation(Id.class);
                        if (id != null) {
                            idValue = (Serializable) method.invoke(o);
                        }
                    }
                } while ((varClass = varClass.getSuperclass()) != null && idValue == null);
View Full Code Here

        Class<? extends Object> varClass = o.getClass();
        do {
                Field[] fields = varClass.getDeclaredFields();
                for (int i = 0; i < fields.length; i++) {
                    Field field = fields[i];
                    Id id = field.getAnnotation(Id.class);
                    if (id != null) {
                       return true;
                    }
                }
        } while ((varClass = varClass.getSuperclass()) != null);
        varClass = o.getClass();
        do {
                    Method[] methods = varClass.getMethods();
                    for (int i = 0; i < methods.length; i++) {
                        Method method = methods[i];
                        Id id = method.getAnnotation(Id.class);
                        if (id != null) {
                            return true;
                        }
                    }
        } while ((varClass = varClass.getSuperclass()) != null );
View Full Code Here

        try{
            do {
                Field[] fields = varClass.getDeclaredFields();
                for (int i = 0; i < fields.length && idValue == null; i++) {
                    Field field = fields[i];
                    Id id = field.getAnnotation(Id.class);
                    if (id != null) {
                        try {
                            idValue = callIdMethod(o, "get"
                                    + Character.toUpperCase(field.getName().charAt(0))
                                    + field.getName().substring(1));
                        } catch (NoSuchMethodException e) {
                            idValue = (Serializable) field.get(o);
                        }
                    }
                }
            } while ((varClass = varClass.getSuperclass()) != null && idValue == null);
            if (idValue == null) {
                varClass = o.getClass();
                do {
                    Method[] methods = varClass.getMethods();
                    for (int i = 0; i < methods.length && idValue == null; i++) {
                        Method method = methods[i];
                        Id id = method.getAnnotation(Id.class);
                        if (id != null) {
                            idValue = (Serializable) method.invoke(o);
                        }
                    }
                } while ((varClass = varClass.getSuperclass()) != null && idValue == null);
View Full Code Here

        Class<? extends Object> varClass = o.getClass();
        do {
                Field[] fields = varClass.getDeclaredFields();
                for (int i = 0; i < fields.length; i++) {
                    Field field = fields[i];
                    Id id = field.getAnnotation(Id.class);
                    if (id != null) {
                       return true;
                    }
                }
        } while ((varClass = varClass.getSuperclass()) != null);
        varClass = o.getClass();
        do {
                    Method[] methods = varClass.getMethods();
                    for (int i = 0; i < methods.length; i++) {
                        Method method = methods[i];
                        Id id = method.getAnnotation(Id.class);
                        if (id != null) {
                            return true;
                        }
                    }
        } while ((varClass = varClass.getSuperclass()) != null );
View Full Code Here

        }

        if (isId) {
            flags = Flag.Id.setTrue(flags);
        } else {
            Id id = field.getAnnotation(Id.class);
            if (id != null) {
                flags = Flag.Id.setTrue(flags);
            }
        }
        column = field.getAnnotation(Column.class);
View Full Code Here

    protected void registerColumnsByAnnotations(Class sqlRowClass) {
        for (Field f : sqlRowClass.getDeclaredFields()) {
            Column anotColumn = f.getAnnotation(Column.class);
            if (anotColumn != null) {
                Id anotColumnPK = f.getAnnotation(Id.class);
                SQLColumn col = null;

                if (anotColumnPK != null) {
                    col = registerColumnPK(anotColumn.name(), f.getName());
                } else {
View Full Code Here

    }
    else {
      Column col = getAnnotation(objectType, parameterName, Column.class);
      if (col != null && ! isNullOrEmpty(col.name()))
        sn = col.name();
      Id id = getAnnotation(objectType, parameterName, Id.class);
      Version version = getAnnotation(objectType, parameterName, Version.class);
      GeneratedValue generated = getAnnotation(objectType, parameterName, GeneratedValue.class);
     
      boolean idFlag = id != null;
      boolean versionFlag = version != null;
View Full Code Here

TOP

Related Classes of javax.persistence.Id

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.