1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)
 

Recent Questions

!!! Hibernate Frequently Asked Questions !!!

How are joins handled using Hinernate.

!!!Answer!!!- From Technical Expert


Best is use Criteria query
Example -
You have parent class
public class Organization {
private long orgId;
private List messages;
}
Child class
public class Message {
    private long messageId;
private Organization organization;
}

.hbm.xml file

<class name="com.bean.Organization" table="ORGANIZATION">
<bag name="messages" inverse="true" cascade="delete" lazy="false">
            <key column="MSG_ID" />
            <one-to-many
                class="com.bean.Message" />
        </bag>



</class>

<class name="com.bean.Message" table="MESSAGE">
    <many-to-one name="organization" column="ORG_ID" lazy="false"/>

</class>
Get all the messages from message table where organisation id = <any id>

Criteria query is :
session.createCriteria(Message.class).createAlias("organization","org").
            add(Restrictions.eq("org.orgId",new Long(orgId))).add(Restrictions.in("statusCode",status)).list();

you can get all the details in hibernate website.
<a href="http://www.hibernate.org/hib_docs/reference/en/html/associations.html">http://www.hibernate.org/hib_docs/reference/en/html/associations.html</a>

Answered By : das Replied Date : May 21 2008
Answer : This helps me lot


Answered By : das Replied Date : May 21 2008
Answer : One to many

A Person can have zero, one or more memos.

<class name="myPackage.Person" table="Person">
<id name="pid" type="int">
<column name="pid" />
<generator class="assigned" />
</id>
...
<set name="memos" cascade="all" lazy="true">
<key column="mpid"/>
<one-to-many class="myPackage.Memos"/>
</set>
</class>

<class name="myPackage.Memos" table="Memos">
<property name="mpid" type="int">
<column name="mpid" />
</property>
<property name="memkz" type="string">
<column name="memkz" length="7">
</column>
</property>

The HQL query can use a left join, so it isselect p from myPackage.Person p
left join p.memos m
where p.id < :maxid
and (m.memkz is null or m.memkz = :memkz)


Answered By : null Replied Date : Jan 30 2014
Answer :


Answered By : null Replied Date : Jan 25 2014
Answer :


Answered By : null Replied Date : Jan 23 2014
Answer :


Answered By : null Replied Date : Dec 4 2013
Answer :


Answered By : null Replied Date : Nov 3 2013
Answer :


Answered By : null Replied Date : Oct 31 2013
Answer :


Answered By : null Replied Date : Oct 25 2013
Answer :


Answered By : null Replied Date : Oct 24 2013
Answer :


Answered By : null Replied Date : Oct 23 2013
Answer :


Answered By : null Replied Date : Feb 7 2014
Answer :


Answered By : null Replied Date : Mar 1 2014
Answer :


Answered By : null Replied Date : Mar 12 2014
Answer :


Answered By : null Replied Date : Jun 7 2014
Answer :


Answered By : null Replied Date : Jun 16 2014
Answer :


Answered By : null Replied Date : Jun 27 2014
Answer :


Answered By : null Replied Date : Jul 6 2014
Answer :


Answered By : null Replied Date : Aug 10 2014
Answer :


Answered By : null Replied Date : Sep 22 2014
Answer :


Answered By : null Replied Date : May 14 2015
Answer :


Answered By : null Replied Date : Jul 11 2015
Answer :


Answered By : null Replied Date : Feb 20 2016
Answer :


Answered By : null Replied Date : Apr 18 2016
Answer :


Answered By : null Replied Date : Jul 14 2017
Answer :


 

You can also contribute to this answer:

Your Name:
Answer:

 
Ask Question and get answer from Expert.
View Answers List from Expert.

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy