Hi Folks,
I need your help regarding hibernate.
I have a form in my jsp page. There are two sections in the form which should be generated dynamically. These 2 sections are only strings. I have a table which contains these strings in 2 columns. This table is only used for fetching purpose, no update,delete,insert. This table will be populated externally by some admin.
The requirement is :
Based on the customer the user belongs an appropriate form description and form declaration(the 2 strings and columns i talked about earlier) will be displayed on the form page.
I need to issue the following DB query in order to fetch the data from the table :
Code:
select form.form_description,form.form_declaration from Organisation org,Subscriber sub,MR_Form_Master form,person_master per
where org.CUST_ID = sub.CUST_ID
and sub.PERSON_ID = per.PERSON_ID
and org.FORM_ID = form.FORM_ID
and per.person_id = 28
There are 4 tables involved in this query in order to fetch the data. The strings belong to MR_Form_Master table.
I have created a MRFormMaster pojo and corresponding hbm file. Following are the codes :
Code:
public class MRFormMaster {
private Integer formId;
private String formName;
private String isActive;
private String formDescription;
private String formDeclaration;
private String createdBy;
private Date createdDate;
private String modifiedBy;
private Date modifiedDate;
......corresponding getters/setters
Code:
<hibernate-mapping>
<class
name="com.nationwide.nsbu.bh.model.MRFormMaster"
table="MR_FORM_MASTER"
>
<id
name="formId"
type="java.lang.Integer"
column="FORM_ID"
>
<!-- <generator class="increment" /> -->
<generator class="sequence">
<param name="sequence">MRFM_FORM_ID</param>
</generator>
</id>
<property
name="formName"
type="java.lang.String"
column="FORM_NAME"
length="100"
/>
<property
name="isActive"
type="java.lang.String"
column="IS_ACTIVE"
length="1"
/>
<property
name="formDescription"
type="java.lang.String"
column="FORM_DESCRIPTION"
length="400"
/>
<property
name="formDeclaration"
type="java.lang.String"
column="FORM_DECLARATION"
length="400"
/>
<property
name="createdBy"
type="java.lang.String"
column="CREATED_BY"
length="101"
/>
<property
name="createdDate"
type="java.sql.Timestamp"
column="CREATED_DATE"
length="7"
/>
<property
name="modifiedBy"
type="java.lang.String"
column="MODIFIED_BY"
length="101"
/>
<property
name="modifiedDate"
type="java.sql.Timestamp"
column="MODIFIED_DATE"
length="7"
/>
</class>
</hibernate-mapping>
How do I write my dao code in order to fetch the data and display it on the form page? I have all the POJOs and hbm files for the other tables i.e Subscriber,Person_Master,Organization. When I am trying to query in hibernate I am getting an object array, not an MRFormMaster instance. As a result of wghich I cannot get the value of formDescription and formDeclaration properties.
Plz help me out. Thanks in advance.
Saurav