Results 1 to 3 of 3

Thread: Hibernate Use

  1. #1
    sireesha is offline Member
    Join Date
    Nov 2007
    Posts
    50
    Rep Power
    0

    Question Hibernate Use

    Hi Every one,
    I am learning Hibernate.For this i am following tutorials form different websites.In every tutorial they gave examples for saving data or to update data.I couldn't find any examples for retrieving data(like retrieving a row depending on some condition ) .Now my doubt is,Can't we use hibernate for retrieving data form a table? If we can,how to do that ? what are different operations that we can perform with hibernate ? Can any one please tell me.
    Thank q very much,
    sireesha.

  2. #2
    ibjava is offline Member
    Join Date
    May 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by sireesha View Post
    Hi Every one,
    Now my doubt is,Can't we use hibernate for retrieving data form a table? If we can,how to do that ?
    we can actually, this example is taken from my application:
    Java Code:
            public List<Deposito> getDepositosPaging(int start, int length) {
    		Session session = getSession();
    		List<Deposito> depositos = (List<Deposito>) session.createQuery("from Deposito where statExist=true order by id ")
    				.setFirstResult(start)
    				.setMaxResults(length).list();
    		
    		return depositos;
    	}
    it retrieve list of Depositos where statExist is true from id=start until id=start+length, ordered by id

  3. #3
    pegitha is offline Member
    Join Date
    Apr 2007
    Location
    Indiana
    Posts
    83
    Rep Power
    0

    Default

    To get one object by primary key:
    getHibernateTemplate().load(MyObject.class, primaryKey);
    for a list using HQL:
    getHibernateTemplate().find("from MyObject obj where obj.recordStatus='A' ");
    or use the Criteria API which personally I think is awesome

Similar Threads

  1. Hibernate, help me
    By Nick15 in forum JDBC
    Replies: 2
    Last Post: 06-05-2008, 04:39 PM
  2. Hibernate DAO
    By sundarjothi in forum Eclipse
    Replies: 0
    Last Post: 04-26-2008, 09:29 AM
  3. hibernate
    By vipinpvijayan in forum Web Frameworks
    Replies: 1
    Last Post: 04-21-2008, 06:41 PM
  4. Replies: 2
    Last Post: 06-30-2007, 04:01 PM
  5. Hibernate
    By Alan in forum JDBC
    Replies: 2
    Last Post: 05-11-2007, 02:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •