Could you please Explain Interfaces in Hibernate

Could you please Explain Interfaces in Hibernate.

Could you please Explain Polymorphism in Hibernate
Manikandan ThiagarajanSenior consultantAsked:
Who is Participating?
for_yanConnect With a Mentor Commented:

These are main insterfaces used in Hibernate:


This is from

The Session is a persistence manager that manages operation like storing and retrieving objects. Instances of Session are inexpensive to create and destroy. They are not thread safe.

The application obtains Session instances from a SessionFactory. SessionFactory instances are not lightweight and typically one instance is created for the whole application. If the application accesses multiple databases, it needs one per database.

The Criteria provides a provision for conditional search over the resultset.One can retrieve entities by composing Criterion objects. The Session is a factory for Criteria.Criterion instances are usually obtained via the factory methods on Restrictions.
Query represents object oriented representation of a Hibernate query. A Query instance is obtained by calling Session.createQuery().
I think this links gives some discussion about polymorphism attribute in hibernate:
Manikandan ThiagarajanSenior consultantAuthor Commented:
I am not clear that polymorphism from that articles.

could you please explain with your own words
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

for_yanConnect With a Mentor Commented:

when you make querries in hibernate and you are looking ofr some entity in the query and
the class corresponding to that entity had attribrtute polymorphism="implicit" , so if you name only
this class in the query, any enitities which represent subclass of this query will still be returned
in your query

if the class in question was specified with polymorphism = "explicit" then when this class is mentioned in queries
only instances of this class will be returned and not some subclasses of this class. Say if two classes are mapped to the
same table and one class is more lightweight (it means that it does not have all parameters - in fact it is parent class)
so if you use its name iin query - you'll not get instances of its "more complicated" subclass.

this is of course rather enough explanation, I think there are details and it not alwyas works this way as I undersand from some posts  in real
implementation, but this explanation reflectes the general idea
Manikandan ThiagarajanSenior consultantAuthor Commented:
what is meant by entity.

one table is connected to another table is called entity
Entity in Hibernate is the class (usually representing some real object - like say Person, Vehicle, Song, etc)
which is mapped to database (as opposed to some other classes in your code which may be more related to processes or gui -
frames, windoes, etc, which are normally not mapped to databse - these are not entitites)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.