Hello dear experts,
I am searching for an approach to dynamically create entities in Berkeley-DB JE. Background is, that I receive an XML file which contains the description of the entity objects and I have to dynamically create the entity objects from the description file.
I would be glad if some could provide me with some hints where to search and if this approach is possible in anyway.
Looking forward to hearing from you.
With kind regards,
using the DPL would be nice but I am afraid that this will be difficult since DPL wants predifined entity classes. So I am searching for a general way to dynamically create content in BDB-JE. Something like SQL-CreateTable.
With kind regards,
Because JE's keys/values are simply byte arrays, it is often used for applications where the schema is dynamic. However, the metadata facility in such applications must be implemented by the application. JE provides a way to dynamically create Databases, of course, but it is up to the application to provide the higher level equivalent of CREATE TABLE.
When creating such an application, you still need to choose a binding -- a serialization format -- from those available: TupleBinding (custom binary format), SerialBinding (Java serialization), the DPL's format, or a creation of your own.
You are correct that the DPL is based on class definitions, so is primarily meant to be static. The same is true of SerialBinding.
So you are left with using tuples, which are very flexible and efficient, or creating something on your own.
There is one other possibility I'll mention, although it is not very space-efficient: You can use the DPL or SerialBinding and define a field of type Map<String, Object> for holding the values. This is inefficient because the field names are repeated in every record -- you might as well store XML or JSON text.
But in all cases you'll need to design and implement the metadata for each table. So the short answer to your question is that JE doesn't help you with this.