Example usage for javax.persistence TemporalType TIME

List of usage examples for javax.persistence TemporalType TIME

Introduction

In this page you can find the example usage for javax.persistence TemporalType TIME.

Prototype

TemporalType TIME

To view the source code for javax.persistence TemporalType TIME.

Click Source Link

Document

Map as java.sql.Time

Usage

From source file:org.apache.camel.bam.model.ActivityState.java

@Temporal(TemporalType.TIME)
public Date getTimeOverdue() {
    return timeOverdue;
}

From source file:org.apache.openjpa.persistence.jdbc.AnnotationPersistenceMappingSerializer.java

/**
 * Return field's temporal type./*  w  w w . j a v a2  s  . c  o  m*/
 */
private TemporalType getTemporal(FieldMapping field) {
    if (field.getDeclaredTypeCode() != JavaTypes.DATE && field.getDeclaredTypeCode() != JavaTypes.CALENDAR)
        return null;

    DBDictionary dict = ((JDBCConfiguration) getConfiguration()).getDBDictionaryInstance();
    int def = dict.getJDBCType(field.getTypeCode(), false);
    for (Column col : (List<Column>) field.getValueInfo().getColumns()) {
        if (col.getType() == def)
            continue;
        switch (col.getType()) {
        case Types.DATE:
            return TemporalType.DATE;
        case Types.TIME:
            return TemporalType.TIME;
        case Types.TIMESTAMP:
            return TemporalType.TIMESTAMP;
        }
    }
    return null;
}

From source file:org.batoo.jpa.core.impl.model.attribute.BasicAttribute.java

/**
 * Constructor for version attributes.// w w  w  .ja  va 2  s. co m
 * 
 * @param declaringType
 *            the declaring type
 * @param metadata
 *            the metadata
 * 
 * @since 2.0.0
 */
public BasicAttribute(IdentifiableTypeImpl<X> declaringType, VersionAttributeMetadata metadata) {
    super(declaringType, metadata);

    this.version = true;
    this.optional = false;
    this.idType = null;
    this.generator = null;
    this.lob = false;
    this.enumType = null;
    this.index = null;
    this.columnTransformer = null;

    this.type = this.getDeclaringType().getMetamodel().createBasicType(this.getJavaType());

    if (this.getJavaType() == Timestamp.class) {
        this.temporalType = TemporalType.TIMESTAMP;
    } else if (this.getJavaType() == java.sql.Date.class) {
        this.temporalType = TemporalType.DATE;
    } else if (this.getJavaType() == java.sql.Time.class) {
        this.temporalType = TemporalType.TIME;
    } else if ((this.getJavaType() == Date.class) || (this.getJavaType() == Calendar.class)) {
        this.temporalType = metadata.getTemporalType() != null ? metadata.getTemporalType()
                : TemporalType.TIMESTAMP;
    } else {
        this.temporalType = null;
    }
}