Dynamic display in sleep mode?

Actually I'm looking for something like this:

You are modifying the table in db (for example adding a column); it should be mirrored in the front end with a hard-coded mapping file ...

Thank you for your help.

+2


source to share


3 answers


hibernate is an ORM. Thus, there is an object model between the interface and the database. How does this object model represent dynamic change? Columns are usually displayed in properties. If you add it to the database, you will still miss the property in the class model.

If you solve the problem in the object model using dictionaries, it is possible to directly map the dictionary as a map, but then the data is not in columns but in rows.



Or you map the dictionary as a dynamic component to be mapped to columns. This is probably what you are looking for.

What I'm trying to say is, first you have to solve the problem in the object model. Then you might ask how this can be compared. If you don't have an object model, you don't need hibernation at all.

+2


source


When Hibernate starts, it maps all columns in domain objects to columns in tables, and these are supported by the SessionFactory. What you want to do is map on the fly, which is not supported, and for that you will need to create your own hybrid JPA / Hibernate. Like @Stephan did, I suggested starting with an object model to make changes (add properties) to your domain's objects and then propagate them to your db.

This would mean that all of your current queries will now take these new properties into account dynamically - if you have queries from DomainObject

then this is not a problem.



My point is that doing what you want creates immediate and non-orthogonal problems that might not have been worth it in my opinion. Let's consider another strategy.

0


source


You can create hibernation configuration and domain classes based on the database schema. Maybe this is what you are looking for? Of course, you will have to compose your application every time you change the database schema.

Maybe you could consider other display tools like iBatis where you can define queries etc. in the configuration.

0


source







All Articles