Package javax.persistence

Examples of javax.persistence.Temporal


    if ( key ) {
      MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
      return ann.value();
    }
    else {
      Temporal ann = property.getAnnotation( Temporal.class );
      return ann.value();
    }
  }
View Full Code Here


    }
    Properties typeParameters = this.typeParameters;
    typeParameters.clear();
    String type = BinderHelper.ANNOTATION_STRING_DEFAULT;
    if ( property.isAnnotationPresent( Temporal.class ) ) {
      Temporal ann = property.getAnnotation( Temporal.class );
      boolean isDate;
      if ( mappings.getReflectionManager().equals( returnedClassOrElement, Date.class ) ) {
        isDate = true;
      }
      else if ( mappings.getReflectionManager().equals( returnedClassOrElement, Calendar.class ) ) {
        isDate = false;
      }
      else {
        throw new AnnotationException(
            "@Temporal should only be set on a java.util.Date or java.util.Calendar property: "
                + StringHelper.qualify( persistentClassName, propertyName )
        );
      }

      switch ( ann.value() ) {
        case DATE:
          type = isDate ? "date" : "calendar_date";
          break;
        case TIME:
          type = "time";
          if ( !isDate ) {
            throw new NotYetImplementedException(
                "Calendar cannot persist TIME only"
                    + StringHelper.qualify( persistentClassName, propertyName )
            );
          }
          break;
        case TIMESTAMP:
          type = isDate ? "timestamp" : "calendar";
          break;
        default:
          throw new AssertionFailure( "Unknown temporal type: " + ann.value() );
      }
    }
    else if ( property.isAnnotationPresent( Lob.class ) ) {

      if ( mappings.getReflectionManager().equals( returnedClassOrElement, java.sql.Clob.class ) ) {
View Full Code Here

    if (key) {
      MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
      return ann.value();
    }
    else {
      Temporal ann = property.getAnnotation( Temporal.class );
      return ann.value();
    }
  }
View Full Code Here

    if (key) {
      MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
      return ann.value();
    }
    else {
      Temporal ann = property.getAnnotation( Temporal.class );
      return ann.value();
    }
  }
View Full Code Here

    if ( key ) {
      MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
      return ann.value();
    }
    else {
      Temporal ann = property.getAnnotation( Temporal.class );
      return ann.value();
    }
  }
View Full Code Here

    if ( key ) {
      MapKeyTemporal ann = property.getAnnotation( MapKeyTemporal.class );
      return ann.value();
    }
    else {
      Temporal ann = property.getAnnotation( Temporal.class );
      return ann.value();
    }
  }
View Full Code Here

        if (ec != null) {
            flags = Flag.Insertable.setFalse(flags);
            flags = Flag.Selectable.setFalse(flags);
        }

        Temporal temporal = field.getAnnotation(Temporal.class);
        if (temporal != null) {
            if (temporal.value() == TemporalType.DATE) {
                flags = Flag.Date.setTrue(flags);
            } else if (temporal.value() == TemporalType.TIME) {
                flags = Flag.Time.setTrue(flags);
            } else if (temporal.value() == TemporalType.TIMESTAMP) {
                flags = Flag.TimeStamp.setTrue(flags);
            }
        }

        if (column != null && column.table().length() > 0) {
View Full Code Here

  } else if (columnType.equals("calendar") || columnType.equals("date")) {
      columnType = "date";
  }
 
  if (columnType.equals("date")) {
      Temporal a = field.getAnnotation(Temporal.class);
      if (a == null) {
    try {
        Method getter = clazz.getMethod("get" + StringUtilities.capitalize(fieldName));
        if (getter != null) {
      a = getter.getAnnotation(Temporal.class);
        }
    } catch (Exception e) {}
      }
      if (a != null && a.value().equals(TemporalType.TIME)) {
    columnType = "time";
      }     
  }
 
  fieldTypeCache.put(clazz.getName() + "." + fieldName, columnType);
View Full Code Here

            attr = getEntityType().getAttribute(dateTimeProvider.getUpdatedDateProperty());
        } catch (IllegalArgumentException e) {
            // noop. This is thrown if the attribute doesn't exist.
        }
        if (attr != null) {
            Temporal temporalAnnotation = null;
            Member member = attr.getJavaMember();
            if (member instanceof Field && ((Field) member).isAnnotationPresent(Temporal.class)) {
                temporalAnnotation = ((Field) member).getAnnotation(Temporal.class);
            } else if (member instanceof Method && ((Method) member).isAnnotationPresent(Temporal.class)) {
                temporalAnnotation = ((Method) member).getAnnotation(Temporal.class);
            }
            if (temporalAnnotation != null) {
                updateDateTimeAware = temporalAnnotation.value() == TemporalType.TIMESTAMP;
                updateDateAware = temporalAnnotation.value() == TemporalType.DATE;
            }
            updateDTRequired = !((SingularAttribute<? super E, ?>) attr).isOptional();
        }
    }
View Full Code Here

            attr = getEntityType().getAttribute(dateTimeProvider.getInsertedDateProperty());
        } catch (IllegalArgumentException e) {
            // noop. This is thrown if the attribute doesn't exist.
        }
        if (attr != null) {
            Temporal temporalAnnotation = null;
            Member member = attr.getJavaMember();
            if (member instanceof Field && ((Field) member).isAnnotationPresent(Temporal.class)) {
                temporalAnnotation = ((Field) member).getAnnotation(Temporal.class);
            } else if (member instanceof Method && ((Method) member).isAnnotationPresent(Temporal.class)) {
                temporalAnnotation = ((Method) member).getAnnotation(Temporal.class);
            }
            if (temporalAnnotation != null) {
                insertDateTimeAware = temporalAnnotation.value() == TemporalType.TIMESTAMP;
                insertDateAware = temporalAnnotation.value() == TemporalType.DATE;
            }
        }
    }
View Full Code Here

TOP

Related Classes of javax.persistence.Temporal

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.