Java Classes without Id parameter

19 views
Skip to first unread message

cem akpolat

unread,
Jul 15, 2019, 9:42:10 AM7/15/19
to Jongo
Hi,

I notice that jongo can also convert the java classes that does not include id variable, but it is written in the jongo.org(mapping section) that each class that has to be converted from document to java object or viceversa has to accomodate id parameter. In the examples in [1], it is possible to insert a coordinate object without id. The question is what is the downside of not having an Id inside the classes. I have a simple API and I want to plan to store the object created through this API, however, there is any specific Id variable that indicates the mongo_document_id. Can anyone explain me, should I update my API and add id parameter into each class under API or just save them without id.

Thanks in advance.


Best regards
Cem

Benoît Guérout

unread,
Jul 16, 2019, 2:39:31 AM7/16/19
to jongo...@googlegroups.com
If you save an object without id, MongoDB will automatically generate an ObjectId before inserting it.

Nevertheless, even if the object has an Object in the database, Jongo will no be able to map the id into your POJO.
This is ok unless you need to get the id in your application.







--
You received this message because you are subscribed to the Google Groups "Jongo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jongo-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jongo-user/09c982c0-70f2-4c38-9a71-3d0ad609696c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages