-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: generate DML statements dynamically in hibernate
PostPosted: Sat Oct 18, 2008 3:48 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11
How to generate DML statements dynamically in hibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 18, 2008 5:25 am 
Regular
Regular

Joined: Wed Oct 15, 2008 6:59 am
Posts: 103
Location: Chennai
U can use Hibernate Query Language to dynamically create DML statements in hibernate..
use this following link as reference
http://www.hibernate.org/hib_docs/refer ... ryhql.html

For eg.,

Code:
Session session=HibernateSessionFactory.getSession();
Transaction txt=session.beginTransaction();
Iterator results=session.createQuery("select u.name,u.age from Users u where u.userId =:uId").setParameter("uId", Integer.parseInt(uid)).iterate();
if(results.hasNext())
{
  Object[]  e = (Object[]) results.next();
  System.out.println("Name: " +e[0].toString());
  System.out.println("Age: " +e[1].toString());
}


Like that you can dynamically create queries as you like...
Take a view the link i specified in the first pace of the post...it's very useful for studying HQL basics and ideas..

_________________
If u feel it will help you, don't forget to rate me....


Top
 Profile  
 
 Post subject: get BAckup of data in the form of DML ..
PostPosted: Sat Oct 18, 2008 7:55 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11
Madan_Prabhu wrote:
U can use Hibernate Query Language to dynamically create DML statements in hibernate..
use this following link as reference
http://www.hibernate.org/hib_docs/refer ... ryhql.html

For eg.,

Code:
Session session=HibernateSessionFactory.getSession();
Transaction txt=session.beginTransaction();
Iterator results=session.createQuery("select u.name,u.age from Users u where u.userId =:uId").setParameter("uId", Integer.parseInt(uid)).iterate();
if(results.hasNext())
{
  Object[]  e = (Object[]) results.next();
  System.out.println("Name: " +e[0].toString());
  System.out.println("Age: " +e[1].toString());
}


Like that you can dynamically create queries as you like...
Take a view the link i specified in the first pace of the post...it's very useful for studying HQL basics and ideas..



Thanks for the quick reply Actually,my problem is that
i want to take backup of all data using hibernate

i m using postgreSql 8.1 as database
Geneally we take database backup using jst right click on database or schema say "Public" and then take backup. Backup is then taken in .backup file.

I want to perform the same operation but using hibernate....

Thanking you!!!!!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 18, 2008 9:02 am 
Regular
Regular

Joined: Thu Sep 06, 2007 2:22 am
Posts: 108
Location: Noida,India
You can generate Database schema by hibernate.

Download pdf document from http://www.manning.com/bauer2/chapter2.pdf and search for "
Exporting the database schema" in this document. Section 2.3 is also give some more information about this.

Hope this will help you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2008 3:40 am 
Newbie

Joined: Sat Oct 11, 2008 3:31 am
Posts: 11
parmendratyagi wrote:
You can generate Database schema by hibernate.

Download pdf document from http://www.manning.com/bauer2/chapter2.pdf and search for "
Exporting the database schema" in this document. Section 2.3 is also give some more information about this.

Hope this will help you.


My task is:
1. To generate schema of current database(DDL script) and write to file.
2. To take backup of all data of that reside in the all tables of current database and restore it whenever I requied.

I have already Exported automatic Schema using SchemaExport class that means my part(1) is done

I m looking for solution of part(2)

I go through your specified link also but i couldnt find desired content in that pdf for solution of part(2)


Thanking You!!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.