[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Could you please Explain Interfaces in Hibernate

Could you please Explain Interfaces in Hibernate.

Could you please Explain Polymorphism in Hibernate
0
Manikandan Thiagarajan
Asked:
Manikandan Thiagarajan
  • 4
  • 2
2 Solutions
 
for_yanCommented:

These are main insterfaces used in Hibernate:

org.hibernate.Session
org.hibernate.SessionFactory
org.hibernate.Criteria
org.hibernate.Query

This is from
http://www.interviewjava.com/2007/06/what-are-core-interfaces-for-hibernate.html

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().
0
 
for_yanCommented:
I think this links gives some discussion about polymorphism attribute in hibernate:

http://v4forums.wordpress.com/2008/12/27/implicit-explicit-polymorphism-in-hibernate/
0
 
Manikandan ThiagarajanSenior consultantAuthor Commented:
I am not clear that polymorphism from that articles.

could you please explain with your own words
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
for_yanCommented:

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
 
0
 
Manikandan ThiagarajanSenior consultantAuthor Commented:
what is meant by entity.

one table is connected to another table is called entity
0
 
for_yanCommented:
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)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now