Answer the question
In order to leave comments, you need to log in
Automating the saving of objects in the database?
Good day.
It is necessary to automate the recording of objects in the database. There are several POJOs. It is necessary to organize their recording in a relational database in such a way that the table name can be set from the program. If not for the last requirement, I would use JPA. Are there any frameworks that allow you to automate the process of writing inserts or something like that?
Answer the question
In order to leave comments, you need to log in
@Table(name = "table_name_goes_here")
Another option I can think of would be to use a database synonym / alias: FOO would be an alias for FOO_JAN2010 until… you change the alias to point on FOO_FEB2010. I've never tested this, I don't know if it will suit your needs. But it's another idea.
The following tricky solution came to mind:
In Hibernate, you can create a configuration using the Configuration class - and import mapping using addInputStream(InputStream xmlInputStream) , and at the same time generate mapping data using some template engine.
Your task is not typical, I don’t think there is a ready-made one, write such a generator yourself. If you do not need to save the graph of objects, then the task is trivial. Otherwise, I would look for other solutions, for example, I would abandon the object graph.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question