开发者

hibernate for dynamic table creation

i AM A HIBERNATE BEGINNER ,Since 开发者_Go百科i need to create dynamic tables with dynamic fields in them i chose to use hibernate . As far as my understanding , creating tables requires a class with the fields defined in the class . How do i generate the classes dynamically based on the table with the required fields ?


I'm not sure I understood the question (the title is about creation of tables, the last part is about creation of classes, pretty confusing). Maybe you should clarify your question and the problem you need to solve.

If you want to create Java classes from the physical model before the runtime, have a look at Hibernate Tools (and especially hbm2java).

If you want to create classes at runtime, I'm afraid this won't be possible with Hibernate. Actually, if your question is about runtime, Hibernate might not be the right tool.


I will be designing the table structure in html form and i want to convert into relevant database model. I should be able to insert and retrieve values from them.

There is jdbcpersistence which generates the mapping classes at runtime. This sounds like it could be what you are looking for. Note that I don't have ANY experience with this tool.


I think that you should definitely have a look over the (experimental but quite stable/mature) Hibernate Dynamic mapping : http://docs.jboss.org/hibernate/core/3.5/reference/en/html/persistent-classes.html#persistent-classes-dynamicmodels

You will have the benefit of using all the features of hibernate (including caching, etc.) and all the power of HQL object-like syntax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜