简体   繁体   English

如何在 spring-data-neo4j 中使用时间戳

[英]How to use time-stamp in spring-data-neo4j

We are using mysql along with hibernate4 for one of our application.我们正在将 mysql 和 hibernate4 用于我们的一个应用程序。 We are storing some error messages in the DB.我们正在数据库中存储一些错误消息。 Below is the class property which used to stores the current time in DB.下面是用于在 DB 中存储当前时间的类属性。

@Column(name = "generation_ts")
private java.sql.Timestamp generationTs;

Now we are trying to store this data in the Neo4J graph DB along with the mysql DB.现在我们试图将这些数据与 mysql 数据库一起存储在 Neo4J 图形数据库中。 Also we don't want to change the current behavior of the class.我们也不想改变类的当前行为。

When I am trying to save this object in Neo4J DB it is throwing the Exception as below:当我试图在 Neo4J DB 中保存这个对象时,它抛出如下异常:

Caused by: java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] at java.sql.Timestamp.valueOf(Timestamp.java:202) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.core.convert.support.ObjectToObjectConverter.convert(ObjectToObjectConverter.java:71)引起:java.lang.IllegalArgumentException:时间戳格式必须是 yyyy-mm-dd hh:mm:ss[.fffffffff] at java.sql.Timestamp.valueOf(Timestamp.java:202) at sun.reflect.NativeMethodAccessorImpl.invoke0 (本机方法)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.lang.reflect.Method.invoke(Method.java:606) ) 在 org.springframework.core.convert.support.ObjectToObjectConverter.convert(ObjectToObjectConverter.java:71)

I have tried this .我试过这个 But It also gives the same exception.但它也给出了同样的例外。

So is there any other way by which I can save this object to mysql DB as well as to Neo4j DB.那么有没有其他方法可以将此对象保存到 mysql DB 以及 Neo4j DB。

I think you can use this to trigger the right converter:我认为您可以使用它来触发正确的转换器:

@GraphProperty(propertyType=long.class)
private java.sql.Timestamp generationTs;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM