D
D
DDwrt1002019-09-26 11:00:37
Java
DDwrt100, 2019-09-26 11:00:37

How to put an arbitrary object into MongoDB using java?

Good afternoon everyone.
Please tell me how to put an arbitrary object in mongoDB. I have xml files with an arbitrary
number of fields at the input. As I understand it, mongo allows you to put records into the collection with an arbitrary number of fields.
However, I don't understand what data structure should be in a Java class? How can I implement this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Frozen Coder, 2019-09-26
@DDwrt100

Options:
1. Write all possible fields in the Java class if you want to use Pojo or any libraries of the Spring Data Mongo type
2. Pre-push the fields and values ​​into the type map Map<String, Object>and then dynamically generate org.bson.Document, as in the example from the mongo documentation -driver
3. Use dynamically typed language instead of Java

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question