Hi, all

How to create report use IReport and Hibernate
I have tried, like this :
:

1. create file hibernate.cfg.xml

xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost/a6</property>
<property name="connection.username">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.password"></property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread
-->
<property name="current_session_context_class">thread</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>

<!-- mapping files -->
<mapping resource="mst/hrd/model/hibernate/hbmxml/T_Karyawan_Ms.hbm.xml"/> 

</session-factory>
</hibernate-configuration>

2. create file T_Karyawan_Ms.java

package mst.hrd.model.hibernate.hbmxml;

import java.io.Serializable;
import java.util.Date;

public class T_Karyawan_Ms implements Serializable{
private String kodePt;
private String karyawanId;
private String namaKaryawan;

public T_Karyawan_Ms() {

}

public String getKodePt() {
return kodePt;
}

public void setKodePt(String kodePt) {
this.kodePt = kodePt;
}

public String getKaryawanId() {
return karyawanId;
}

public void setKaryawanId(String karyawanId) {
this.karyawanId = karyawanId;
}

public String getNamaKaryawan() {
return namaKaryawan;
}

public void setNamaKaryawan(String namaKaryawan) {
this.namaKaryawan = namaKaryawan;
}


}

3. create file T_Karyawan_Ms.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="mst.hrd.model.hibernate.hbmxml">
<class name="T_Karyawan_Ms" table="t_karyawan_ms">

<composite-id>
<key-property name="kodePt" type="string" column="KODE_PT" />
<key-property name="karyawanId" type="string" column="KARYAWAN_ID"/>
</composite-id>

<property name="namaKaryawan" type="string" column="NAMA_KARYAWAN"/>
</class>

</hibernate-mapping>

4. create HibernateProperties.java

public static void hibernateProperties(String typeDb){
CVariable var = new CVariable(); 
String user=var.getUserMst();
String pwd=var.getPwdMst();

configuration = new Configuration()
.addClass(mst.hrd.model.hibernate.hbmxml.T_Karyawan_Ms.class) 
.setProperty("hibernate.dialect","org.hibernate.dialect.MySQLInnoDBDialect")
.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver")
.setProperty("hibernate.connection.url", "jdbc:mysql://"+var.host+ "/"+var.dbGlobal+"")
.setProperty("hibernate.connection.username", user)
.setProperty("hibernate.connection.password", pwd);
}

In iReport I used step :
1. Seting classpath OptionsClasspathadd folder  all folder src
3. Data Connection/Data SourceNew Hibernate connection Next type conhibernate
4. click test  show error
Error : component class not found: mst.hrd.model.hibernate.hbmxml.T_Karyawan_Ms

what step must i doing ?

I using ireport 2.0
Thanks,

can anybody tell me how to get hibernate connection with ireport using netbeans ide6.7.1???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.