HQL
Hibernate provides a simplified language for querying into the database. Its called HQL-Hibernate Query language.
We can use SQL Queries directly in hibernate,So naturally a question may come.Whats the need of using HQL if you can perform the same with SQL ?
1.HQL is very simple. Its very easy to learn and manipulate.
2. HQL engine generates the most appropriate SQL for a particular task from a set of SQL statements.
3.Usage of HQL will help in application portability. We can change the Database from say Oracle to MySQL without changing any HQL queries. Only change needed is in the Configuration file where we need to specify the appropriate driver and dialect.
These are some of the advantages of using HQL. I will keep you updated with more advantages soon.
iText
iText is the free and open source library in Java used for generating PDF, RTF and HTML documents. It is very simple to use and manipulate. For the .NET framework there is iTextSharp similar to iText.
iText was developed by Bruno Lowagie in 1998. If you are interested in the history and what made him develop iText, Visit More on iText .
You can easily tryout the following piece of code provided you have JDK and any IDE. Download the iText.jar from and add it to the project .You can download the jar file from here.
Sample code:
/*Importing the necesary packages*/
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
import java.io.FileOutputStream;
/*Sample code for creating a new pdf document and writing into it
*@author guru_G
*/
public class SampleCode{
public static void main(String[] args) {
try{
Document pdf = new Document();
/**
*This will create a new document in the following
*path D:\ with name Document.pdf
**/
FileOutputStream file=new FileOutputStream("D:\\Document.pdf");
PdfWriter.getInstance(pdf,file);
pdf.open();
/*Adding a new paragraph in the document*/
pdf.add(new Paragraph("Manchester United"));
pdf.close();
}catch(Exception e){
System.out.println("Exception caught :"+e.getMessage());
}
}
}
Run the project and a new file will be created in D:\ with name document.pdf .
-
Archives
- February 2012 (1)
- July 2009 (1)
- June 2009 (1)
- May 2009 (7)
-
Categories
-
RSS
Entries RSS
Comments RSS