gis_wild
gis_wild

Reputation: 462

hibernate: create Entity(with annotations) in runtime

Is it possible to create hibernate Entity class(with annotations) during runtime? It should be related with the table that is also added in runtime. It is important that the Entity should be visible by the Hibernate. Is it possible in general, could you please give me any advices on the problem? I understand, that reflection is the keyword, but looking for some more words. Regards.

Upvotes: 10

Views: 8391

Answers (2)

Lord
Lord

Reputation: 31

You don't need to create a POJO entity class and instance at run time. What you need is the Hibernate dynamic models. Please refer to http://docs.jboss.org/hibernate/orm/4.3/manual/en-US/html_single/#persistent-classes-dynamicmodels.

Upvotes: 3

Akash Yadav
Akash Yadav

Reputation: 2421

In This scenario, you might want to create the Hibernate Session Factory programatic on the run time , passing in the new mapping that you have created , have a look at http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/session-configuration.html#configuration-programmatic for details .

Upvotes: 4

Related Questions