Showing posts with label Hibernet. Show all posts
Showing posts with label Hibernet. Show all posts

Monday, August 29, 2011

Hibernate - Store and Retrieve Data along with BLOB as XML

Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database.

Here, i have demostrated basic example to store data along with blob into Database and retrieve from Database.File logic is used to display Blob Data only. While writing your own Logic, you should avoid it.

Before Using this tutorial, You need know how hibernate Configuration "hibernate.cfg.xml" should look like. Read related blog post - Hibernate config file

Contact.java - Pojo file containing getter and setter methods.

package com.core;

import java.io.Serializable;
import java.sql.Blob;

/**
 * @author Anuj Patel
 * Java Core POJO class to map to database Contact Table
 */
public class Contact implements Serializable{
    private String firstName;
    private String lastName;
    private String email;
    private int id;  
    private Blob contactData;
  
    public Blob getContactData() {
        return contactData;
    }
    public void setContactData(Blob contactData) {
        this.contactData = contactData;
    }
    public String getFirstName() {
        return firstName;
    }
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    public String getLastName() {
        return lastName;
    }    public void setLastName(String lastName) {
        this.lastName = lastName;
    }    public String getEmail() {
        return email;
    }    public void setEmail(String email) {
        this.email = email;
    }  
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
}


Friday, May 07, 2010

Hibernet and Hibernet Dialect Properties


Hibernate supports many database.
Following are list of databases dialect type property:

* DB2 - org.hibernate.dialect.DB2Dialect
* HypersonicSQL - org.hibernate.dialect.HSQLDialect
* Informix - org.hibernate.dialect.InformixDialect
* Ingres - org.hibernate.dialect.IngresDialect
* Interbase - org.hibernate.dialect.InterbaseDialect
* Pointbase - org.hibernate.dialect.PointbaseDialect
* PostgreSQL - org.hibernate.dialect.PostgreSQLDialect
* Mckoi SQL - org.hibernate.dialect.MckoiDialect
* Microsoft SQL Server - org.hibernate.dialect.SQLServerDialect
* MySQL - org.hibernate.dialect.MySQLDialect
* Oracle (any version) - org.hibernate.dialect.OracleDialect
* Oracle 9 - org.hibernate.dialect.Oracle9Dialect
* Progress - org.hibernate.dialect.ProgressDialect
* FrontBase - org.hibernate.dialect.FrontbaseDialect
* SAP DB - org.hibernate.dialect.SAPDBDialect
* Sybase - org.hibernate.dialect.SybaseDialect
* Sybase Anywhere - org.hibernate.dialect.SybaseAnywhereDialect