Thanks for your reply. When I use your formula,it gives me the sql error near the key word if.However,this is not I want. What I want is when the method contact.performLoadById(int id) is invoked, it will load the info of the Contact. Besides,in the Contact,it has a Customer field(represented by its id),I just like to load only that particular Customer if its id is not 0.
My map is:
Code:
<hibernate-mapping>
<class name="com.mcwsoftware.iuxserver.model.Contact" table="CONTACT">
<id name="contactId" type="int" column="ContactId" >
<generator class="native"/>
</id>
<property name="firstName">
<column name="FirstName"/>
</property>
<property name="lastName">
<column name="LastName"/>
</property>
<many-to-one name="customer" column="CustomerId" fetch="join" foreign-key="FK_Contact_Customer" not-found="ignore" />
</hibernate-mapping>
<hibernate-mapping>
<class name="com.mcwsoftware.iuxserver.model.Customer" table="CUSTOMER">
<id name="customerId" type="int" column="CustomerId" >
<generator class="increment"/>
</id>
Code:
<property name="companyName">
<column name="CompanyName"/>
</property>
</hibernate-mapping>
Once again,thanks again for your reply.