Could you please Explain Interfaces in Hibernate

Posted on 2011-10-18
Last Modified: 2013-11-24
Could you please Explain Interfaces in Hibernate.

Could you please Explain Polymorphism in Hibernate
Question by:stmani2005
    LVL 47

    Accepted Solution


    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().
    LVL 47

    Expert Comment

    I think this links gives some discussion about polymorphism attribute in hibernate:
    LVL 8

    Author Comment

    I am not clear that polymorphism from that articles.

    could you please explain with your own words
    LVL 47

    Assisted Solution


    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
    LVL 8

    Author Comment

    what is meant by entity.

    one table is connected to another table is called entity
    LVL 47

    Expert Comment

    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)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
    The viewer will learn how to implement Singleton Design Pattern in Java.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now