javax.persistence.Temporal Java Examples

The following examples show how to use javax.persistence.Temporal. 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
Source File: JPAOverriddenAnnotationReader.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
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 #2
Source File: ModelTableImpl.java    From tephra with 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 #3
Source File: DynamicEntityBuilder.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #4
Source File: DynamicEntityBuilder.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #5
Source File: DocumentData.java    From cia with 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 #6
Source File: SwedenPoliticalParty.java    From cia with 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 #7
Source File: CommitteeDocumentData.java    From cia with 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
Source File: BookedTrip.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "booked", nullable = false, length = 10)
public Date getBooked() {
	return this.booked;
}
 
Example #9
Source File: Enterprise.java    From dpCms with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "ADD_DATE", nullable = false, length = 10)
public Date getAddDate() {
	return this.addDate;
}
 
Example #10
Source File: UserTeam.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "APPROVE_DATE", length = 19)
public Date getApproveDate() {
    return this.approveDate;
}
 
Example #11
Source File: OrganizationData.java    From development with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
public Long getDeregistrationDate() {
    return deregistrationDate;
}
 
Example #12
Source File: Discuss.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "PUBLISH_DATE", length = 19)
public Date getPublishDate() {
    return this.publishDate;
}
 
Example #13
Source File: File.java    From PhotoAlbum-api with MIT License 4 votes vote down vote up
@Column(name = "created_date")
@Temporal(TemporalType.TIMESTAMP)
public Date getCreatedDate() {
	return this.createdDate;
}
 
Example #14
Source File: StudentClasses.java    From sample-java-spring-genericdao with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "STU_CLASSES_BEGIN_DATE", nullable = false, length = 7)
public Date getStuClassesBeginDate() {
	return this.beginDate;
}
 
Example #15
Source File: StudentClasses.java    From sample-java-spring-genericdao with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "STU_CLASSES_END_DATE", length = 7)
public Date getStuClassesEndDate() {
	return this.endDate;
}
 
Example #16
Source File: Instructor.java    From sample-java-spring-genericdao with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "INSTRUCTOR_BIRTHDAY", nullable = false, length = 7)
public Date getBirthday() {
	return this.birthday;
}
 
Example #17
Source File: Department.java    From dpCms with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "MODIFY_DATE", length = 10)
public Date getModifyDate() {
	return this.modifyDate;
}
 
Example #18
Source File: Challenge.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CHALLENGE_DATE", length = 19)
public Date getChallengeDate() {
    return this.challengeDate;
}
 
Example #19
Source File: Post.java    From dpCms with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "ADD_DATE", length = 10)
public Date getAddDate() {
	return this.addDate;
}
 
Example #20
Source File: HrmsEmployeeDetails.java    From Spring-MVC-Blueprints with 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 #21
Source File: User.java    From Spring-MVC-Blueprints with 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 File: Comment.java    From TinyMooc with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "COMMENT_DATE", length = 19)
public Date getCommentDate() {
    return this.commentDate;
}
 
Example #23
Source File: PurchaseOrder.java    From Spring-MVC-Blueprints with 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 #24
Source File: HrmsEmployeeProjects.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "dateEnded", length = 10)
public Date getDateEnded() {
	return this.dateEnded;
}
 
Example #25
Source File: Tblstudents.java    From Spring-MVC-Blueprints with 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 #26
Source File: HrmsEmployeeProjects.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "dateStarted", nullable = false, length = 10)
public Date getDateStarted() {
	return this.dateStarted;
}
 
Example #27
Source File: CfsFeedback.java    From Spring-MVC-Blueprints with 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 File: InstructorClasses.java    From sample-java-spring-genericdao with Apache License 2.0 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "INS_CLASSES_BEGIN_DATE", nullable = false, length = 7)
public Date geBeginDate() {
	return this.beginDate;
}
 
Example #29
Source File: CfsTopic.java    From Spring-MVC-Blueprints with 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 File: HrmsEmployeeDetails.java    From Spring-MVC-Blueprints with MIT License 4 votes vote down vote up
@Temporal(TemporalType.DATE)
@Column(name = "employedDate", nullable = false, length = 10)
public Date getEmployedDate() {
	return this.employedDate;
}