--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/fe1352d7-6f9b-4e97-a488-c9a8d088521d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Joo,Are you using Cassandra? Cassandra has a native timestamp data type: http://docs.datastax.com/en/cql/3.3/cql/cql_reference/cql_data_types_c.htmlYou can use that to declare the column type.The built-in mappings from Java types to CQL types are documented here: http://docs.datastax.com/en/developer/java-driver/3.0/manual/#cql-to-java-type-mappingAs you can see there, the default mapping for timestamp is to java.util.Date, however the Cassandra Java driver lets you register custom codecs for translating other data types. They also provide an optional library called "cassandra-driver-extras" that includes custom codecs for some common classes, including java.time.Instant: http://docs.datastax.com/en/developer/java-driver/3.0/manual/custom_codecs/extras/#jdk-8To use this in your Lagom service, you need to:
- Add a dependency on the cassandra-driver-extras library to your project (in build.sbt or pom.xml). Make sure to use the right version to match the cassandra-driver-core version used by your app.
- Register the InstantCodec somewhere in your app initialization, probably in the prepare handler for your read-side processor.
The Online Auction app has an example of this (using EnumCodec rather than InstantCodec):
- https://github.com/lagom/online-auction-java/blob/master/build.sbt#L46
- https://github.com/lagom/online-auction-java/blob/master/item-impl/src/main/java/com/example/auction/item/impl/ItemRepository.java#L173
Cheers,Tim
On Fri, Jan 6, 2017 at 10:38 PM, Joo Lee <joo.an...@gmail.com> wrote:
Hey guys,How do you guys handle java.time.Instant in Lagom?What I do right now is when storing, I create a column with BIGINT as a type, and then I insert instant.toEpochMilli() for insertion and I do Instant.ofEpochMilli(timestamp)load it back.I think it works but it is bit tedious. How do you guys handle it?Cheers,Joo
--
You received this message because you are subscribed to the Google Groups "Lagom Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framewo...@googlegroups.com.
To post to this group, send email to lagom-f...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/fe1352d7-6f9b-4e97-a488-c9a8d088521d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/ce7e92cf-2b7a-418f-9eb0-28946043bd4c%40googlegroups.com.To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/ce7e92cf-2b7a-418f-9eb0-28946043bd4c%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to lagom-framework+unsubscribe@googlegroups.com.
To post to this group, send email to lagom-framework@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lagom-framework/7eb93de0-0632-4632-a20b-d45f2d91a636%40googlegroups.com.