Class SqlTimestamp
- java.lang.Object
-
- java.util.Date
-
- java.sql.Timestamp
-
- org.datanucleus.store.types.wrappers.SqlTimestamp
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<java.util.Date>
,SCO<java.sql.Timestamp>
public class SqlTimestamp extends java.sql.Timestamp implements SCO<java.sql.Timestamp>
A mutable second-class SQL timestamp object.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractMemberMetaData
ownerMmd
protected DNStateManager
ownerSM
-
Constructor Summary
Constructors Constructor Description SqlTimestamp(DNStateManager sm, AbstractMemberMetaData mmd)
Creates aSqlTimestamp
object that represents the time at which it was allocated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
attachCopy(java.sql.Timestamp value)
Method to return an attached version for the passed StateManager and field, using the passed value.java.lang.Object
clone()
Creates and returns a copy of this object.java.sql.Timestamp
detachCopy(FetchPlanState state)
Method to detach a copy of this object.java.lang.String
getFieldName()
Accessor for the field namejava.lang.Object
getOwner()
Accessor for the owner.java.sql.Timestamp
getValue()
Accessor for the unwrapped value that we are wrapping.void
initialise()
Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store).void
initialise(java.sql.Timestamp ts)
Method to initialise the SCO for use with the provided initial value.void
initialise(java.sql.Timestamp newValue, java.lang.Object oldValue)
Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value.void
makeDirty()
Utility to mark the object as dirtyvoid
setDate(int date)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.DAY_OF_MONTH, int date)
.void
setHours(int hours)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.HOUR_OF_DAY, int hours)
.void
setMinutes(int minutes)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MINUTE, int minutes)
.void
setMonth(int month)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MONTH, int month)
.void
setNanos(int time_nanos)
Mutator for the time in nanos.void
setSeconds(int seconds)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.SECOND, int seconds)
.void
setTime(long time)
Mutator for the time.void
setYear(int year)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.YEAR, year + 1900)
.void
unsetOwner()
Utility to unset the owner.protected java.lang.Object
writeReplace()
The writeReplace method is called when ObjectOutputStream is preparing to write the object to the stream.-
Methods inherited from class java.sql.Timestamp
after, before, compareTo, compareTo, equals, equals, from, getNanos, getTime, hashCode, toInstant, toLocalDateTime, toString, valueOf, valueOf
-
-
-
-
Field Detail
-
ownerSM
protected transient DNStateManager ownerSM
-
ownerMmd
protected transient AbstractMemberMetaData ownerMmd
-
-
Constructor Detail
-
SqlTimestamp
public SqlTimestamp(DNStateManager sm, AbstractMemberMetaData mmd)
Creates aSqlTimestamp
object that represents the time at which it was allocated.- Parameters:
sm
- StateManager for the owning objectmmd
- Metadata for the member
-
-
Method Detail
-
initialise
public void initialise()
Description copied from interface:SCO
Method to initialise the SCO for use, and allowing the SCO to be loaded from the datastore (when we have a backing store). This can be utilised to perform any eager loading of information from the datastore.- Specified by:
initialise
in interfaceSCO<java.sql.Timestamp>
-
initialise
public void initialise(java.sql.Timestamp newValue, java.lang.Object oldValue)
Description copied from interface:SCO
Method to initialise the SCO for use, where replacing an old value with a new value such as when calling a setter field passing in a new value. Note that oldValue is marked as Object since for cases where the member type is Collection the newValue could be, for example, ArrayList, and the oldValue of type Collection (representing null).- Specified by:
initialise
in interfaceSCO<java.sql.Timestamp>
- Parameters:
newValue
- New value (to wrap)oldValue
- Old value (to use in deciding what needs deleting etc)
-
initialise
public void initialise(java.sql.Timestamp ts)
Description copied from interface:SCO
Method to initialise the SCO for use with the provided initial value. This is used, for example, when retrieving the field from the datastore and setting it in the persistable object.- Specified by:
initialise
in interfaceSCO<java.sql.Timestamp>
- Parameters:
ts
- the object from which to copy the value.
-
getValue
public java.sql.Timestamp getValue()
Accessor for the unwrapped value that we are wrapping.
-
unsetOwner
public void unsetOwner()
Utility to unset the owner.- Specified by:
unsetOwner
in interfaceSCO<java.sql.Timestamp>
-
getOwner
public java.lang.Object getOwner()
Accessor for the owner.
-
getFieldName
public java.lang.String getFieldName()
Accessor for the field name- Specified by:
getFieldName
in interfaceSCO<java.sql.Timestamp>
- Returns:
- The field name
-
makeDirty
public void makeDirty()
Utility to mark the object as dirty
-
detachCopy
public java.sql.Timestamp detachCopy(FetchPlanState state)
Method to detach a copy of this object.- Specified by:
detachCopy
in interfaceSCO<java.sql.Timestamp>
- Parameters:
state
- State for detachment process- Returns:
- The detached object
-
attachCopy
public void attachCopy(java.sql.Timestamp value)
Method to return an attached version for the passed StateManager and field, using the passed value.- Specified by:
attachCopy
in interfaceSCO<java.sql.Timestamp>
- Parameters:
value
- The new value
-
clone
public java.lang.Object clone()
Creates and returns a copy of this object.Mutable second-class Objects are required to provide a public clone method in order to allow for copying persistable objects. In contrast to Object.clone(), this method must not throw a CloneNotSupportedException.
-
setTime
public void setTime(long time)
Mutator for the time.- Overrides:
setTime
in classjava.sql.Timestamp
- Parameters:
time
- The time (millisecs)
-
setNanos
public void setNanos(int time_nanos)
Mutator for the time in nanos.- Overrides:
setNanos
in classjava.sql.Timestamp
- Parameters:
time_nanos
- The time (nanos)
-
setYear
@Deprecated public void setYear(int year)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.YEAR, year + 1900)
.Sets the year of this Date object to be the specified value plus 1900. ThisDate
object is modified so that it represents a point in time within the specified year, with the month, date, hour, minute, and second the same as before, as interpreted in the local time zone. (Of course, if the date was February 29, for example, and the year is set to a non-leap year, then the new date will be treated as if it were on March 1.)- Overrides:
setYear
in classjava.util.Date
- Parameters:
year
- the year value.- See Also:
Calendar
-
setMonth
@Deprecated public void setMonth(int month)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MONTH, int month)
.Sets the month of this date to the specified value. This Date object is modified so that it represents a point in time within the specified month, with the year, date, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was October 31, for example, and the month is set to June, then the new date will be treated as if it were on July 1, because June has only 30 days.- Overrides:
setMonth
in classjava.util.Date
- Parameters:
month
- the month value between 0-11.- See Also:
Calendar
-
setDate
@Deprecated public void setDate(int date)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.DAY_OF_MONTH, int date)
.Sets the day of the month of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified day of the month, with the year, month, hour, minute, and second the same as before, as interpreted in the local time zone. If the date was April 30, for example, and the date is set to 31, then it will be treated as if it were on May 1, because April has only 30 days.- Overrides:
setDate
in classjava.util.Date
- Parameters:
date
- the day of the month value between 1-31.- See Also:
Calendar
-
setHours
@Deprecated public void setHours(int hours)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.HOUR_OF_DAY, int hours)
.Sets the hour of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified hour of the day, with the year, month, date, minute, and second the same as before, as interpreted in the local time zone.- Overrides:
setHours
in classjava.util.Date
- Parameters:
hours
- the hour value.- See Also:
Calendar
-
setMinutes
@Deprecated public void setMinutes(int minutes)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.MINUTE, int minutes)
.Sets the minutes of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified minute of the hour, with the year, month, date, hour, and second the same as before, as interpreted in the local time zone.- Overrides:
setMinutes
in classjava.util.Date
- Parameters:
minutes
- the value of the minutes.- See Also:
Calendar
-
setSeconds
@Deprecated public void setSeconds(int seconds)
Deprecated.As of JDK version 1.1, replaced byCalendar.set(Calendar.SECOND, int seconds)
.Sets the seconds of this Date to the specified value. This Date object is modified so that it represents a point in time within the specified second of the minute, with the year, month, date, hour, and minute the same as before, as interpreted in the local time zone.- Overrides:
setSeconds
in classjava.util.Date
- Parameters:
seconds
- the seconds value.- See Also:
Calendar
-
writeReplace
protected java.lang.Object writeReplace() throws java.io.ObjectStreamException
The writeReplace method is called when ObjectOutputStream is preparing to write the object to the stream. The ObjectOutputStream checks whether the class defines the writeReplace method. If the method is defined, the writeReplace method is called to allow the object to designate its replacement in the stream. The object returned should be either of the same type as the object passed in or an object that when read and resolved will result in an object of a type that is compatible with all references to the object.- Returns:
- the replaced object
- Throws:
java.io.ObjectStreamException
- if an error occurs
-
-