Java Code Examples for javax.persistence.Temporal

The following examples show how to use javax.persistence.Temporal. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void createDateField(Builder builder, Field field) {

		AnnotationSpec column = AnnotationSpec.builder(Column.class)
				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();

		AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
				.addMember("value", "javax.persistence.TemporalType.DATE").build();
		FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
				.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(Date.class).addStatement("return this." + field.getName())
				.build();
		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Date.class, field.getName())
				.addStatement("this." + field.getName() + " = " + field.getName()).build();
		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);

	}
 
Example 2
private void createDateTimeField(Builder builder, Field field) {

		AnnotationSpec column = AnnotationSpec.builder(Column.class)
				.addMember("name", "ColumnNamePrefix + " + field.fieldName()).build();

		AnnotationSpec temporal = AnnotationSpec.builder(Temporal.class)
				.addMember("value", "javax.persistence.TemporalType.TIMESTAMP").build();

		FieldSpec fieldSpec = FieldSpec.builder(Date.class, field.getName(), Modifier.PRIVATE)
				.addAnnotation(this.fieldDescribe(field)).addAnnotation(this.index(field))
				.addAnnotation(this.checkPersist(field)).addAnnotation(column).addAnnotation(temporal).build();
		MethodSpec get = MethodSpec.methodBuilder("get" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(Date.class).addStatement("return this." + field.getName())
				.build();
		MethodSpec set = MethodSpec.methodBuilder("set" + StringUtils.capitalize(field.getName()))
				.addModifiers(Modifier.PUBLIC).returns(void.class).addParameter(Date.class, field.getName())
				.addStatement("this." + field.getName() + " = " + field.getName()).build();
		builder.addField(this.fieldName(field)).addField(fieldSpec).addMethod(get).addMethod(set);

	}
 
Example 3
private void getTemporal(List<Annotation> annotationList, Element element) {
	Element subElement = element != null ? element.element( "temporal" ) : null;
	if ( subElement != null ) {
		AnnotationDescriptor ad = new AnnotationDescriptor( Temporal.class );
		String temporal = subElement.getTextTrim();
		if ( "DATE".equalsIgnoreCase( temporal ) ) {
			ad.setValue( "value", TemporalType.DATE );
		}
		else if ( "TIME".equalsIgnoreCase( temporal ) ) {
			ad.setValue( "value", TemporalType.TIME );
		}
		else if ( "TIMESTAMP".equalsIgnoreCase( temporal ) ) {
			ad.setValue( "value", TemporalType.TIMESTAMP );
		}
		else if ( StringHelper.isNotEmpty( temporal ) ) {
			throw new AnnotationException( "Unknown TemporalType: " + temporal + ". " + SCHEMA_VALIDATION );
		}
		annotationList.add( AnnotationFactory.create( ad ) );
	}
}
 
Example 4
Source Project: tephra   Source File: ModelTableImpl.java    License: MIT License 6 votes vote down vote up
@Override
public void addGetMethod(String name, Method method) {
    getMethods.put(name, method);
    Jsonable jsonable = method.getAnnotation(Jsonable.class);
    if (jsonable != null)
        jsonables.put(name, jsonable);
    ManyToOne manyToOne = method.getAnnotation(ManyToOne.class);
    if (manyToOne != null)
        manyToOnes.put(name, manyToOne);

    Class<?> type = method.getReturnType();
    Temporal temporal = method.getAnnotation(Temporal.class);
    if (temporal != null) {
        if (TemporalType.DATE.equals(temporal.value()))
            type = Date.class;
        else if (TemporalType.TIMESTAMP.equals(temporal.value()))
            type = Timestamp.class;
    }
    types.put(name, type);
    addLowerCase(name);
}
 
Example 5
Source Project: cia   Source File: SwedenPoliticalParty.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Gets the registered date.
*
* @return the registered date
*/
  @Basic
  @Column(name = "REGISTERED_DATE")
  @Temporal(TemporalType.DATE)
  public Date getRegisteredDate() {
      return registeredDate;
  }
 
Example 6
Source Project: cia   Source File: DocumentData.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Gets the made public date.
*
* @return the made public date
*/
  @Basic
  @Column(name = "MADE_PUBLIC_DATE")
  @Temporal(TemporalType.DATE)
  public Date getMadePublicDate() {
      return madePublicDate;
  }
 
Example 7
Source Project: cia   Source File: CommitteeDocumentData.java    License: Apache License 2.0 5 votes vote down vote up
/**
* Gets the created date.
*
* @return the created date
*/
  @Basic
  @Column(name = "CREATED_DATE")
  @Temporal(TemporalType.DATE)
  public Date getCreatedDate() {
      return createdDate;
  }
 
Example 8
@Temporal(TemporalType.DATE)
@Column(name = "INS_CLASSES_END_DATE", length = 7)
public Date getEndDate() {
	return this.endDate;
}
 
Example 9
Source Project: we-cmdb   Source File: AdmUserAccess.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "acc_time")
public Date getAccTime() {
    return this.accTime;
}
 
Example 10
Source Project: we-cmdb   Source File: AdmOperateRecord.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "start_time")
public Date getStartTime() {
    return this.startTime;
}
 
Example 11
Source Project: we-cmdb   Source File: VersionTable.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "version_date")
public Date getVersionDate() {
    return this.versionDate;
}
 
Example 12
Source Project: TinyMooc   Source File: OperationLog.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "LOG_DATE", length = 19)
public Date getLogDate() {
    return this.logDate;
}
 
Example 13
Source Project: TinyMooc   Source File: Authority.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "UPDATE_DATE", length = 19)
public Date getUpdateDate() {
    return this.updateDate;
}
 
Example 14
Source Project: pacbot   Source File: RhnSystemDetails.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Gets the creates the date.
 *
 * @return the creates the date
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "createDate", length = 19)
public Date getCreateDate() {
    return this.createDate;
}
 
Example 15
Source Project: pacbot   Source File: RhnSystemDetails.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Gets the modified date.
 *
 * @return the modified date
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "modifiedDate", length = 19)
public Date getModifiedDate() {
    return this.modifiedDate;
}
 
Example 16
Source Project: pacbot   Source File: RhnSystemDetails.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Gets the last checked in.
 *
 * @return the last checked in
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "lastCheckedIn", length = 19)
public Date getLastCheckedIn() {
    return this.lastCheckedIn;
}
 
Example 17
Source Project: aws-photosharing-example   Source File: User.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
public Date getLastLogin() {return lastLogin;}
 
Example 18
Source Project: aws-photosharing-example   Source File: Media.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
public Date getPresignedUrlExpires() {return this.presignedUrlExpires;}
 
Example 19
Source Project: TinyMooc   Source File: Favorite.java    License: Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "FAVORITE_DATE", length = 19)
public Date getFavoriteDate() {
    return this.favoriteDate;
}
 
Example 20
Source Project: lams   Source File: SimpleValueBinder.java    License: GNU General Public License v2.0 4 votes vote down vote up
private void applyAttributeConverter(XProperty property, ConverterDescriptor attributeConverterDescriptor) {
	if ( attributeConverterDescriptor == null ) {
		return;
	}

	LOG.debugf( "Starting applyAttributeConverter [%s:%s]", persistentClassName, property.getName() );

	if ( property.isAnnotationPresent( Id.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for Id attribute [%s]", property.getName() );
		return;
	}

	if ( isVersion ) {
		LOG.debugf( "Skipping AttributeConverter checks for version attribute [%s]", property.getName() );
		return;
	}

	if ( !key && property.isAnnotationPresent( Temporal.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]", property.getName() );
		return;
	}
	if ( key && property.isAnnotationPresent( MapKeyTemporal.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyTemporal [%s]", property.getName() );
		return;
	}

	if ( !key && property.isAnnotationPresent( Enumerated.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]", property.getName() );
		return;
	}
	if ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyEnumerated [%s]", property.getName() );
		return;
	}

	if ( isAssociation() ) {
		LOG.debugf( "Skipping AttributeConverter checks for association attribute [%s]", property.getName() );
		return;
	}

	this.attributeConverterDescriptor = attributeConverterDescriptor;
}
 
Example 21
Source Project: Spring-MVC-Blueprints   Source File: CustomerAccount.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", nullable = false, length = 10)
public Date getBirthDate() {
	return this.birthDate;
}
 
Example 22
Source Project: Spring-MVC-Blueprints   Source File: CustomerAccount.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "startDate", nullable = false, length = 10)
public Date getStartDate() {
	return this.startDate;
}
 
Example 23
Source Project: Spring-MVC-Blueprints   Source File: Catalog.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "expiry", nullable = false, length = 10)
public Date getExpiry() {
	return this.expiry;
}
 
Example 24
Source Project: Spring-MVC-Blueprints   Source File: CustomerAccount.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", nullable = false, length = 10)
public Date getBirthDate() {
	return this.birthDate;
}
 
Example 25
Source Project: Spring-MVC-Blueprints   Source File: CustomerAccount.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "startDate", nullable = false, length = 10)
public Date getStartDate() {
	return this.startDate;
}
 
Example 26
Source Project: Spring-MVC-Blueprints   Source File: Person.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", length = 10)
public Date getBirthDate() {
	return this.birthDate;
}
 
Example 27
Source Project: Spring-MVC-Blueprints   Source File: Invoice.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "date", nullable = false, length = 10)
public Date getDate() {
	return this.date;
}
 
Example 28
Source Project: Spring-MVC-Blueprints   Source File: User.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", nullable = false, length = 10)
public Date getBirthDate() {
	return this.birthDate;
}
 
Example 29
Source Project: Spring-MVC-Blueprints   Source File: PurchaseOrder.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "date", nullable = false, length = 10)
public Date getDate() {
	return this.date;
}
 
Example 30
Source Project: Spring-MVC-Blueprints   Source File: Tblstudents.java    License: MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "birthDate", nullable = false, length = 10)
public Date getBirthDate() {
	return this.birthDate;
}