Coder Social home page Coder Social logo

Comments (3)

arielvardi avatar arielvardi commented on September 6, 2024

New to simeplejpa and seeing the same thing. Would love some pointers on best practices to serialize/deserialize these fields.

from simplejpa.

treeder avatar treeder commented on September 6, 2024

SimpleJPA was probably made before SimpleDBUtils was available and I believe the encoding we used was common practice to ensure it was padded properly and sortable. For example: http://aws.amazon.com/articles/1232

Happy to take pull requests though if you want to make it configurable.

from simplejpa.

bertramn avatar bertramn commented on September 6, 2024

Inspecting the Hibernate type mapping support would be a good start. Hibernate has a default strategy to map types to the underlying Dialect. There is a default strategy for type mapping and if specified otherwise a custom one.

Them main reason for needing the choice is SimpleDB stores everything as text and hence for searching and ordering, one will need to convert the types into lexical formats that will allow proper ordering.

E.g. for integer values we could calculate an offset (as currently done by the simplejpa entitymanager) that is lexically sortable.

// default strategy @Type(type = "org.spaceprogram.simpejpa.IntegerOffsetType")
@Column(name = "some_int_field")
private int someIntegerField;

Input: 2
Result: 09223372036854775810

Then we could create other type mapping strategies for the integer like below:

@Type(type = "org.spaceprogram.simpejpa.IntegerPaddedType")
@Column(name = "some_int_field")
private int someIntegerField;

Input: 2
Result: 0000000000000000002

Internalized dates is another area where this could be beneficial. E.g if we have dates with timezone offset we need to convert them all to UTC times to be properly sortable. Or sometimes they need to be local, as in show me all flights that depart prior to 6:00am at airport local time across the US.

from simplejpa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.