Example #1
0
 public static boolean isGenerated(Field field) {
   Id id = field.getAnnotation(Id.class);
   if (id != null) {
     Class<?> type = field.getType();
     // ONLY long ID can be auto_incremented
     if (id.value() == Generator.AUTO_INCREMENT
         && (Long.TYPE == type || Long.class.isAssignableFrom(type))) {
       return true;
     }
     if (id.value() == Generator.UUID
         && (String.class.isAssignableFrom(type) || UUID.class.isAssignableFrom(type))) {
       return true;
     }
   }
   return false;
 }
Example #2
0
 private void buildId(Field field) {
   Class<?> type = field.getType();
   Id id = field.getAnnotation(Id.class);
   if (id != null) {
     // ONLY long ID can be auto_incremented
     if (id.value() == Generator.AUTO_INCREMENT
         && (Long.TYPE == type || Long.class.isAssignableFrom(type))) {
       generatedKeys.add(field);
     } else {
       insertFields.add(field);
     }
     keys.add(field);
     allFields.add(field);
     allExtendedFields.add(field);
   }
 }