Example usage for javax.persistence TemporalType TIMESTAMP

List of usage examples for javax.persistence TemporalType TIMESTAMP

Introduction

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

Prototype

TemporalType TIMESTAMP

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

Click Source Link

Document

Map as java.sql.Timestamp

Usage

From source file:ru.apertum.qsystem.common.model.QCustomer.java

@Column(name = "finish_time")
@Temporal(TemporalType.TIMESTAMP)
public Date getFinishTime() {
    return finishTime;
}

From source file:org.opennms.netmgt.model.OnmsAlarm.java

/**
 * <p>getAlarmAckTime</p>/*from w  w w  . ja va  2s  .  c om*/
 *
 * @return a {@link java.util.Date} object.
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "alarmAckTime")
@XmlElement(name = "ackTime")
public Date getAlarmAckTime() {
    return this.m_alarmAckTime;
}

From source file:gov.nih.nci.firebird.data.Protocol.java

/**
 * @return the lastUpdated/*from   www  . ja v  a2 s .c o  m*/
 */
@Column(name = "last_update")
@Temporal(TemporalType.TIMESTAMP)
public Date getLastUpdate() {
    if (lastUpdate != null) {
        return (Date) lastUpdate.clone();
    }
    return null;
}

From source file:org.opennms.netmgt.model.OnmsAlarm.java

/**
 * <p>getLastEventTime</p>/* w  ww .  ja  v  a 2  s  . co m*/
 *
 * @return a {@link java.util.Date} object.
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "lastEventTime")
@XmlElement(name = "lastEventTime")
public Date getLastEventTime() {
    return m_lastEventTime;
}

From source file:org.opennms.netmgt.model.OnmsAlarm.java

/**
 * <p>getFirstAutomationTime</p>
 *
 * @return a {@link java.util.Date} object.
 *//* w  ww  .j a  v  a2 s . c om*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "firstAutomationTime")
@XmlElement(name = "firstAutomationTime")
public Date getFirstAutomationTime() {
    return m_firstAutomationTime;
}

From source file:org.opennms.netmgt.model.OnmsAlarm.java

/**
 * <p>getLastAutomationTime</p>
 *
 * @return a {@link java.util.Date} object.
 *///  ww w .  j  a v a2 s  .co  m
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "lastAutomationTime")
@XmlElement(name = "lastAutomationTime")
public Date getLastAutomationTime() {
    return m_lastAutomationTime;
}

From source file:com.newline.view.company.entity.NlCompanyEntity.java

@Column(name = "CREATEDTIME", nullable = true)
@Temporal(TemporalType.TIMESTAMP)
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public java.util.Date getCreatedtime() {
    return createdtime;
}

From source file:myorg.relex.One2OneTest.java

/**
 * This test demonstrates use of cascades in a one-to-one 
 * uni-directional relationship or one where all cascades come
 * from the owning/dependent side.//from   ww w  . ja  v a2 s  . co m
 */
@Test
public void testOne2OneCascadeFromOwner() {
    log.info("*** testOne2OneCascadeFromOwner ***");
    License license = new License();
    license.setRenewal(new GregorianCalendar(2012, 1, 1).getTime());
    LicenseApplication licapp = new LicenseApplication(license);
    licapp.setUpdated(new Date());
    em.persist(licapp);
    em.flush();

    //detach the current instances and obtain new instances
    assertTrue("licapp was not managed???", em.contains(licapp));
    assertTrue("license was not managed???", em.contains(license));
    em.detach(licapp);
    assertFalse("licapp still managed", em.contains(licapp));
    assertFalse("license still managed", em.contains(license));
    licapp = em.find(LicenseApplication.class, licapp.getId());
    license = licapp.getLicense();

    //perform a bulk update and refresh on the entities to synchronize state
    Date newDate = new GregorianCalendar(2014, 1, 1).getTime();
    Date newUpdate = new Date(licapp.getUpdated().getTime() + 1);
    assertEquals("unexpected update count", 1,
            em.createQuery("update License lic set lic.renewal=:renewal where lic.id=:id")
                    .setParameter("renewal", newDate, TemporalType.DATE).setParameter("id", license.getId())
                    .executeUpdate());
    assertEquals("unexpected update count", 1,
            em.createQuery("update LicenseApplication licapp set licapp.updated=:updated where licapp.id=:id")
                    .setParameter("updated", newUpdate, TemporalType.TIMESTAMP)
                    .setParameter("id", licapp.getId()).executeUpdate());
    assertFalse("unexpected updated value prior to refresh",
            licapp.getUpdated().getTime() == newUpdate.getTime());
    assertFalse("unexpected renewal value prior to refresh",
            license.getRenewal().getTime() == newDate.getTime());
    log.info("database updated");
    em.refresh(licapp);
    log.info("entities refreshed");
    DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
    assertTrue(String.format("licapp not refreshed, exp=%s, act=%s", df.format(newUpdate),
            df.format(licapp.getUpdated())), licapp.getUpdated().getTime() == newUpdate.getTime());
    assertTrue(String.format("license not refreshed, exp=%s, act=%s", df.format(newDate),
            df.format(license.getRenewal())), license.getRenewal().getTime() == newDate.getTime());

    //detach, change, and merge changes from the detached entities
    em.detach(licapp);
    newDate = new GregorianCalendar(2016, 1, 1).getTime();
    newUpdate = new Date(licapp.getUpdated().getTime() + 1);
    assertFalse("licapp still managed", em.contains(licapp));
    assertFalse("license still managed", em.contains(licapp.getLicense()));
    licapp.setUpdated(newUpdate);
    licapp.getLicense().setRenewal(newDate);
    log.info("merging changes to detached entities");
    licapp = em.merge(licapp);
    em.flush();
    log.info("merging complete");
    assertTrue("merged licapp not managed", em.contains(licapp));
    assertTrue("merged licapp.license not managed", em.contains(licapp.getLicense()));
    assertTrue(String.format("licapp not merged, exp=%s, act=%s", df.format(newUpdate),
            df.format(licapp.getUpdated())), licapp.getUpdated().getTime() == newUpdate.getTime());
    assertTrue(
            String.format("license not merged, exp=%s, act=%s", df.format(newDate),
                    df.format(license.getRenewal())),
            licapp.getLicense().getRenewal().getTime() == newDate.getTime());

    //delete remaining objects
    em.remove(licapp);
    em.flush();
    assertNull("licapp not deleted", em.find(LicenseApplication.class, licapp.getId()));
    assertNull("licapp.license not deleted", em.find(License.class, licapp.getLicense().getId()));
}

From source file:com.newline.view.company.entity.NlCompanyEntity.java

@Column(name = "UPDATETIME", nullable = true)
@Temporal(TemporalType.TIMESTAMP)
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
public java.util.Date getUpdatetime() {
    return updatetime;
}

From source file:org.mitre.oauth2.model.ClientDetailsEntity.java

/**
 * @return the createdAt
 */
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_at")
public Date getCreatedAt() {
    return createdAt;
}