Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate Dynamic Models

Tags:

java

hibernate

I am going through the Hibernate documentation and came across the concept of Hibernate Dynamic Models : Dynamic models

I understood that using Dynamic Models concept we need not write any POJO classes separately and we just need to write a mapping file. Practically when we will be using this feature?

Also the document says:

One of the main advantages of dynamic mapping is quick turnaround time for prototyping, without the need for entity class implementation. However, you lose compile-time type checking and will likely deal with many exceptions at runtime. As a result of the Hibernate mapping, the database schema can easily be normalized and sound, allowing to add a proper domain model implementation on top later on.

Can you please help me in understanding the advantages of it, I was not able to get what it means.

Also the document says:

Session dynamicSession = pojoSession.getSession(EntityMode.MAP);

Please note that the call to getSession() using an EntityMode is on the Session API, not the SessionFactory. That way, the new Session shares the underlying JDBC connection, transaction, and other context information. This means you do not have to call flush() and close() on the secondary Session, and also leave the transaction and connection handling to the primary unit of work.

In this I understand that pojoSession is same as Session object and what is the secondary Session as per the statements.

Please help me in understanding the dynamic models concept of Hibernate 3.x.

like image 372
Chaitanya Avatar asked Oct 21 '13 21:10

Chaitanya


1 Answers

Dynamic Models can be used in any application where users or administrators can modify the content models at runtime. Basically most Content Management Systems allow this. So it's possible to use Hibernate as a kind of Content Repository.

like image 160
Thomas Koch Avatar answered Oct 01 '22 18:10

Thomas Koch