Kevin, So if I need nanosecond, the Date precision should be 1,right? Regards, Yu Wang
On Wed, Jun 20, 2012 at 9:28 PM, Kevin Sutter <kwsut...@gmail.com> wrote: > Good to hear, Yu! > > It's kind of strange, but the base units used for timestamps are > Nanoseconds. So, the DatePrecision specifies what multiplier to use to get > the desired precision. Multiply Nanos by 1000 and you get Micros. The > default value for DatePrecision is 1000000, which then translates to Millis. > > Kevin > > On Wed, Jun 20, 2012 at 4:54 AM, yu wang <wangy...@gmail.com> wrote: > >> Kevin, >> It does work. Thanks! By the way, what does "DatePrecision=1000" mean? Why >> 1000? >> >> Regards, >> Yu Wang >> >> >> On Tue, Jun 19, 2012 at 10:04 PM, Kevin Sutter <kwsut...@gmail.com> wrote: >> > Thanks, Yu, for the clarification. >> > >> > By default, OpenJPA uses Millisecond precision on the date fields (least >> > common denominator). Some of the data dictionaries have been updated to >> > Microsecond (DB2, Postgres, etc) or even Nanosecond (Ingres). It looks >> > like the Oracle dictionary is still using the default Millisecond >> > precision. You can easily update this by modifying the Oracle dictionary >> > as follows: >> > >> > <property name="openjpa.jdbc.DBDictionary" >> value="oracle(DatePrecision=1000)"/> >> > >> > If this does the trick for you and you feel that the default precision >> for >> > the Oracle dictionary should be Microseconds, please file a JIRA [1]. >> > >> > Thanks, Kevin >> > >> > [1] http://openjpa.apache.org/found-a-bug.html >> > >> > On Mon, Jun 18, 2012 at 11:24 PM, yu wang <wangy...@gmail.com> wrote: >> > >> >> Kevin >> >> Before the field is persisted, I use toString() method of Timestamp >> >> object to print the value of the field, its precision is microsecond. >> >> But when I read the Timestamp field from DB, its precision is >> millisecond. >> >> >> >> I need the precision of this Timestamp filed is microsecond. I am >> >> using ORacle DB and I can insert microsecond Timestamp filed into DB >> >> by SQL directly. >> >> >> >> Thanks, >> >> Yu Wang >> >> >> >> On Mon, Jun 18, 2012 at 9:43 PM, Kevin Sutter <kwsut...@gmail.com> >> wrote: >> >> > Hi Yu, >> >> > Can you clarify your request? You said that your Timestamp fields >> are >> >> > persisted to the DB at a millisecond level. But, I'm not following >> your >> >> > "print" comments and microsecond precision level. After retrieved >> from >> >> the >> >> > DB, are the Timestamps still at a millisecond precision? Or, are you >> >> > looking to store the Timestamp to the DB at a microsecond precision? >> >> > Various databases have different practices as it comes to Timestamp >> >> > precision. If you could clarify what your expectations are, maybe >> >> > something can be figured out. Thanks. >> >> > >> >> > Kevin >> >> > >> >> > On Mon, Jun 18, 2012 at 4:31 AM, yu wang <wangy...@gmail.com> wrote: >> >> > >> >> >> Hello, >> >> >> I am using OpenJPA 1.2.2 connecting oracle DB. >> >> >> For Timestamp field, the precision is always millisecond level after >> >> >> the filed is persisted into DB, regardless of I print the timestampe >> >> >> filed in java, its precision is microsecond level. >> >> >> Any specific configuration I am not aware of? >> >> >> >> >> >> Below is a sample: >> >> >> @Basic() >> >> >> @Column(name="LOGTIME") >> >> >> public java.sql.Timestamp getLogtime() { >> >> >> return this.logtime; >> >> >> } >> >> >> @Override >> >> >> public void setLogtime(java.sql.Timestamp logtime) { >> >> >> this.logtime = logtime; >> >> >> } >> >> >> >> >> >> Regards, >> >> >> Yu Wang >> >> >> >> >> >>