Advertisement :
   Log In    OR    Register  
  Topics :  
RMI Example

Home >>> Hibernate Tutorial >>> Hibernate Criteria >>> Hibernate query
Struts Tutorials:
Struts2 Tag CheckBoxList
, Checkbox, Iterator, IF
Struts2 Tag Library Example Struts2 Tiles Example Struts2 Tiles I18N Example Struts2 Questions Struts Tiles I18N Example Struts Eclipse MVC Struts2 Tags Struts2 Example and Tutorial Struts MVC Struts2 Validation
Hibernate Tutorials: Hibernate Case Study Class Hierarchy Persist Example Using Hibernate Interceptor Hibernate Questions with Answer Hibernate Many-to-Many Mapping Example Hibernate one-to-many Mapping Example Hibernate and ORM tools Spring Hibernate Example Hibernate SessionFactory Example Hibernate Mapping Class Hierarchy Hibernate Questions Hibernate SessionFactory Questions Spring Hibernate Example: Spring Hibernate Case Study

Written By : Amit
Title :
ways create Hibernate SessionFactory
Description : Example
More...


Written By : Amit
Title :
Spring Hibernate Integration example
Description : Example
More...


Written By : Amit
Title :
ORM Hibernate Best FIT
Description : Discussion
More...


Written By : Amit
Title :
One to Many mapping example
Description : Code
More...


Written By : Amit
Title :
Many to Many Mapping Example
Description : code
More...


Written By : Amit
Title :
Interview questions answer
Description : discussion
More...


Written By : Amit
Title :
Interceptor use log SQL statements
Description : example code
More...


Written By : Amit
Title :
Class Hierarchy Persist example
Description : code
More...

Tags/Keywords : Hibernate Criteria, Hibernate Query, Hibernate, Example, Code, Tutorial, Article
Author : Amit
Date (Year/Month/Date): 2009-05-25 Question on Hibernate Criteria Suppose there is a one to many mapping between person and role. While quering Person based on certain role, if a filter criteria is required based on role only, Is there any ways one can do such mapping with some filter criteria?? Or any other ways of doing Hibernate Query criteria on dependent objects?? Let me discuss this scenario with this example, A person can have many roles such as Manager, Assistant manager, general manager, secretary, Architect etc. So when this person object is queried, then roles to be queried should have Manager roles only, like Manager, Assistant manager, general manager and not Secretary and Achitect. One way it can be by providing a Hibernate named query and other way could be by creating Hibernate Criteria and providing appropriate Restrictions in Java code. Can someone take this as a task and complete this example with a very simple example on Hibernate Criteria and publish this Hibernate Criteria example in this Page? As we are discussing about using filters with Hibernate Entities, then one can look more towards the Hibernate Filters, such as <filter-def> Tag in Hibernate mapping file. It can be used along with a class Tag and/or with collection tags as well. This <filter-def> tag can use parameters begining with : and these parameters can be used in code to set values. Session has method enableFilter(FILTER_NAME) to get Filter object. All parameters value can be set on this Filter object, in order to provide a filter criteria to the mapping. To the best of my understanding, using Hibernate to form query based on certain filter criterias, one can use Hibernate Session api, methods like
  • createCriteria(ENTITY_NAME) to get a Criteria, and work with Restrictions to come up with query filter requirements
  • createQuery(QUERY_NAME) to get a Query and work to set appropriate values to parameters and then executeUpdate or list all the results of this query.
  • getNamedQuery(QUERY_NAME) to get Query as defined in HBM mapping file, to be executed to retrieve appropriate values from Resultset.

  • Advertisement :

    
    
    	
    Are you interested in solving a very interesting Technology Stack while Playing this Game          

    Please write your Comment on this Matter
    (This will be visible if found suitable):
    Name: *
    Email (will not be displayed): *
    Matter: *
    40,12
    Enter bigger number from above :*
    Home >>> Hibernate Tutorial >>> Hibernate Criteria >>> Hibernate query
    Visitor/User referred related external URL:
    (Visible upon review and approved by this site Administrator)
    
    Referred By Name *:
    Resource URL *: (e.g, URL should be starting with http://www.-----.---)
     
    Resource Short Description *:
    38,39
    Enter bigger number from above : *

    Please log in to add or reply to any matter<- requires login
    Log in or Register
    Copyright © 2008-2009, Interview-Questions-Tips-Forum, All Rights Reserved.
    CONTACT    PRIVACY POLICY    DISCLAIMER
    Terms of Use and Disclaimer :
    
    This web site provides some of the information about various technologies, example 
    code, tips, tutorials etc. Like any printed materials, content of these pages may 
    become out of date over a period of time. Therefore all visitor/users of this web 
    site are requested/advised to refer to the originating parties/sources for the 
    latest changes and happenings for detailed information. This information is not 
    intended to be a substitute for the original reference provided by the originating 
    parties/sources.
    
    By accessing and using this website in any ways, including, without
    limitation, browsing the website pages, using any information, using any content and/or 
    downloading any materials, you agree to and are bound by the terms of use 
    described in this page and Usage Terms and Conditions. 
    If you do not agree to all of 
    the terms and conditions contained in the terms of use described in this
    page and Usage Terms and Conditions, do not use this 
    website in any manner. If you are using the website on behalf of your 
    employer, you represent that you are authorized to accept these Terms of Use 
    on your employer's behalf.
    
    All Trademarks are property of their respective owner. Appropriate measure is being
    taken for providing accurate and up-to-date information but like any printed materials,
    these blog(s)/contents may eventually be outdated one day, so if you are using any 
    of these information, please refer original content/documentation from respective sources. 
    And under no circumstances shall the Author of these contents and/or this web site
    be liable for any loss, damage, expense incurred or suffered which is claimed to have
    occurred because of usage of the contents of this web site.
    If you have any questions/queries/feedback/suggestions then please write to this web
    site owner at contact.