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:org.nuxeo.ecm.activity.ActivityImpl.java

@Temporal(TemporalType.TIMESTAMP)
@Column
@Override
public Date getLastUpdatedDate() {
    return lastUpdatedDate;
}

From source file:org.nuxeo.ecm.platform.audit.impl.LogEntryImpl.java

/**
 * Returns the date of the event that originated the log entry.
 *
 * @return the date of the event that originated the log entry
 *//*from ww  w  .j a v  a  2 s  .  co m*/
@Override
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "LOG_EVENT_DATE")
public Date getEventDate() {
    return eventDate;
}

From source file:org.nuxeo.ecm.platform.audit.impl.LogEntryImpl.java

/**
 * @return the date of the log insertion: this up to max transaction timeout later than eventDate. This date is
 *         useful for services such as Nuxeo Drive that need fine grained incremental near-monotonic access to the
 *         audit log.//from   www .java 2  s  . c  o m
 * @since 5.7
 * @since 5.6-HF16
 */
@Override
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "LOG_DATE")
public Date getLogDate() {
    return logDate;
}

From source file:org.olat.core.util.mail.manager.MailManagerImpl.java

/**
 * Load all mails with the identity as recipient, only mails which are not deleted
 * for this user. Recipients are NOT loaded if not explicitly wanted!
 * @param identity//from   ww w.j a v  a2s . co m
 * @param unreadOnly
 * @param fetchRecipients
 * @param from
 * @param firstResult
 * @param maxResults
 * @return
 */
@Override
public List<DBMailLight> getInbox(Identity identity, Boolean unreadOnly, Boolean fetchRecipients, Date from,
        int firstResult, int maxResults) {
    StringBuilder sb = new StringBuilder();
    String fetchOption = (fetchRecipients != null && fetchRecipients.booleanValue()) ? "fetch" : "";
    sb.append("select mail from ").append(DBMailLightImpl.class.getName()).append(" mail")
            .append(" inner join fetch ").append(" mail.from fromRecipient").append(" inner join ")
            .append(fetchOption).append(" mail.recipients recipient").append(" inner join ").append(fetchOption)
            .append(" recipient.recipient recipientIdentity")
            .append(" where recipientIdentity.key=:recipientKey and recipient.deleted=false");
    if (unreadOnly != null && unreadOnly.booleanValue()) {
        sb.append(" and recipient.read=false");
    }
    if (from != null) {
        sb.append(" and mail.creationDate>=:from");
    }
    sb.append(" order by mail.creationDate desc");

    TypedQuery<DBMailLight> query = dbInstance.getCurrentEntityManager()
            .createQuery(sb.toString(), DBMailLight.class).setParameter("recipientKey", identity.getKey());
    if (maxResults > 0) {
        query.setMaxResults(maxResults);
    }
    if (firstResult > 0) {
        query.setFirstResult(firstResult);
    }
    if (from != null) {
        query.setParameter("from", from, TemporalType.TIMESTAMP);
    }

    List<DBMailLight> mails = query.getResultList();
    return mails;
}

From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java

@SuppressWarnings("unchecked")
public UserActionList getUserActionsByTypeAndDay(String type, String day, int offset, int limit) {
    UserActionList result = new UserActionListImpl();

    int year = Integer.parseInt(day.substring(0, 4));
    int month = Integer.parseInt(day.substring(4, 6)) - 1;
    int date = Integer.parseInt(day.substring(6, 8));

    Calendar calBegin = new GregorianCalendar();
    calBegin.set(year, month, date, 0, 0);
    Calendar calEnd = new GregorianCalendar();
    calEnd.set(year, month, date, 23, 59);

    result.setTotal(getTotal(type, calBegin, calEnd));
    result.setOffset(offset);/*from www. ja  v a2  s  .c o  m*/
    result.setLimit(limit);

    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("findUserActionsByTypeAndIntervall");
        q.setParameter("type", type);
        q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
        q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
        q.setFirstResult(offset);
        q.setMaxResults(limit);
        Collection<UserAction> userActions = q.getResultList();

        for (UserAction a : userActions) {
            result.add(a);
        }
        return result;
    } finally {
        if (em != null && em.isOpen()) {
            em.close();
        }
    }
}

From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java

private int getTotal(String type, Calendar calBegin, Calendar calEnd) {
    EntityManager em = null;//from w  w  w . j a  v a  2 s. c o m
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("findTotalByTypeAndIntervall");
        q.setParameter("type", type);
        q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
        q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        if (em != null && em.isOpen()) {
            em.close();
        }
    }
}

From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java

@SuppressWarnings("unchecked")
public UserActionList getUserActionsByDay(String day, int offset, int limit) {
    UserActionList result = new UserActionListImpl();

    int year = Integer.parseInt(day.substring(0, 4));
    int month = Integer.parseInt(day.substring(4, 6)) - 1;
    int date = Integer.parseInt(day.substring(6, 8));

    Calendar calBegin = new GregorianCalendar();
    calBegin.set(year, month, date, 0, 0);
    Calendar calEnd = new GregorianCalendar();
    calEnd.set(year, month, date, 23, 59);

    result.setTotal(getTotal(calBegin, calEnd));
    result.setOffset(offset);/*from   w  ww  .  ja v a  2  s.c o  m*/
    result.setLimit(limit);

    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("findUserActionsByIntervall");
        q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
        q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
        q.setFirstResult(offset);
        q.setMaxResults(limit);
        Collection<UserAction> userActions = q.getResultList();

        for (UserAction a : userActions) {
            result.add(a);
        }
        return result;
    } finally {
        if (em != null && em.isOpen()) {
            em.close();
        }
    }
}

From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java

private int getTotal(Calendar calBegin, Calendar calEnd) {
    EntityManager em = null;/*from w w w  .  j ava2  s .c  o m*/
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("findTotalByIntervall");
        q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
        q.setParameter("end", calEnd, TemporalType.TIMESTAMP);
        return ((Long) q.getSingleResult()).intValue();
    } finally {
        if (em != null && em.isOpen()) {
            em.close();
        }
    }
}

From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java

public Report getReport(String from, String to, int offset, int limit) throws ParseException {
    Report report = new ReportImpl();
    report.setLimit(limit);//from  ww  w .  j av a 2 s.  c om
    report.setOffset(offset);

    Calendar calBegin = new GregorianCalendar();
    Calendar calEnd = new GregorianCalendar();
    SimpleDateFormat complex = new SimpleDateFormat("yyyyMMddhhmm");
    SimpleDateFormat simple = new SimpleDateFormat("yyyyMMdd");

    //Try to parse the from calendar
    try {
        calBegin.setTime(complex.parse(from));
    } catch (ParseException e) {
        calBegin.setTime(simple.parse(from));
    }

    //Try to parse the to calendar
    try {
        calEnd.setTime(complex.parse(to));
    } catch (ParseException e) {
        calEnd.setTime(simple.parse(to));
    }

    EntityManager em = null;
    try {
        em = emf.createEntityManager();
        Query q = em.createNamedQuery("countSessionsGroupByMediapackageByIntervall");
        q.setFirstResult(offset);
        q.setMaxResults(limit);
        q.setParameter("begin", calBegin, TemporalType.TIMESTAMP);
        q.setParameter("end", calEnd, TemporalType.TIMESTAMP);

        @SuppressWarnings("unchecked")
        List<Object[]> result = q.getResultList();
        ReportItem item;

        for (Object[] a : result) {
            item = new ReportItemImpl();
            item.setEpisodeId((String) a[0]);
            item.setViews((Long) a[1]);
            item.setPlayed((Long) a[2]);
            report.add(item);
        }
        return report;
    } finally {
        if (em != null && em.isOpen()) {
            em.close();
        }
    }
}

From source file:org.openhie.openempi.model.AuditEvent.java

@Temporal(TemporalType.TIMESTAMP)
@Column(name = "date_created", nullable = false, length = 8)
public Date getDateCreated() {
    return dateCreated;
}