Announcement Announcement Module
No announcement yet.
Are there any plans to support type "Long" as a type for the "id" property? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Are there any plans to support type "Long" as a type for the "id" property?


    Are there any plans to support type "Long" as a type for the "id" property? Currently with my mongo backed repository when I attempt to save my business object that has a property Id of type Long, I get the exception

    Invalid data type java.lang.Long for Id property. Should be one of [class org.bson.types.ObjectId, class java.lang.String, class java.math.BigInteger, class [B]

    In my app I have two underlying persistences - I use mongo for backing my unit tests and JPA for backing my real implementation. Not supporting Long as the id makes it difficult to seamlessly switch between the two.

    I don't like the idea of using ObjectId as it is mongo specific, and when I try using BigInteger I get serialization exceptions ... that only leaves String :-(


  • #2
    Also, just to give a little more background of why I ask ...

    I am currently storing my test data in bson files that I load into mongo db using the mongoimport.exe app. In these my _id property is a long. These import quite well.

    Using spring data they also load quite well and I am able to retrieve them using the normal find operations. When I retrieve them in, however, the id property on my business object is null (presumably because Long is not a supported type), but apart from that there are no complaints.

    I can edit these retrieved objects and even setId(..) on them and use save() to save the object without complaint (although save() doesn't work in this scenario, again presumably because Long isn't supported and the connection between id and _id is broken as a result, but it does update the the original object retrieved!)

    I only start to get complaints about the valid datatypes for Id when I create a brand new business object and try to save() through the repository.


    • #3
      any news on this? should we create a jira issue?