Programmer's path to quantitative transaction (17) -- Cointrader's Temporal entity (5); programmer's path to quantitative transaction

Source: Internet
Author: User

Programmer's path to quantitative transaction (17) -- Cointrader's Temporal entity (5); programmer's path to quantitative transaction

Reprint need to note: http://blog.csdn.net/minimicall,http://cloudtrader.top/

This section describes a time entity Temporal entity, and its code is very simple.

package org.cryptocoinpartners.schema;import java.util.Date;import javax.persistence.Basic;import javax.persistence.MappedSuperclass;import javax.persistence.Transient;import org.hibernate.annotations.Type;import org.joda.time.Instant;/** * @author Tim Olson */
// This annotation indicates that this class is also a base class and will not create a table in the Database @ MappedSuperclasspublic class Temporal extends EntityBase {public Temporal (Instant time) {super (); this. time = time; this. dateTime = time. toDate (); this. timestamp = time. getMillis ();}/** For Events, this is the time the Event itself occured, not the time we have Ed the Event. it shoshould be remote * server time if available, and local time if the object was created locally */
// @/Type annotation is used to describe the Type @ type (Type = "org. jadira. usertype. dateandtime. joda. persistentInstantAsMillisLong ") @ Basic (optional = false) public Instant getTime () {return time ;}// This annotation is used to indicate that the field is not stored in the database @ Transient public Date getDateTime () {return dateTime ;}@ Transient public long getTimestamp () {return timestamp;} // JPA protected Temporal () {} protected void setTime (Instant time) {this. time = time; this. dateTime = time. toDate (); this. timestamp = time. getMillis ();} protected Instant time; // time private long timestamp; // time cut private Date dateTime; // Date}

It must be noted that this class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.