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)

Hibernate interview questions

!!! Hibernate interview questions !!!

Hibernate setup using .cfg.xml file ?

The XML configuration file is by default expected to be in the root o your CLASSPATH. Here is an example:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
<!-- a SessionFactory instance listed as /jndi/name -->
<!-- properties -->
<property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">false</property>
<property name="transaction.factory_class">
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- mapping files -->
<mapping resource="org/hibernate/auction/Cost.hbm.xml"/>
As you can see, the advantage of this approach is the externalization of the mapping file names to configuration.
The hibernate.cfg.xml is also more convenient once you have to tune the Hibernate cache. Note that is
your choice to use either hibernate.properties or hibernate.cfg.xml, both are equivalent, except for the
above mentioned benefits of using the XML syntax.
With the XML configuration, starting Hibernate is then as simple as
SessionFactory sf = new Configuration().configure().buildSessionFactory();
You can pick a different XML configuration file using
SessionFactory sf = new Configuration()

Cost.hbm.xml -----> looks like

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

<class name="com.bean.Cost" table="COST">

<id name="id" column="ID">
<property name="isQueued" type="int" column="IS_QUEUED"/>
<property name="queueDate" type="timestamp" column="QUEUE_DATE"/>
<property name="lastModifiedDate" type="timestamp" column="LAST_MODIFIED_DATE"/>
<property name="lastModifiedBy" column="LAST_MODIFIED_BY"/>
<property name="amount" column="AMOUNT" type="double"/>
<property name="currencyCode" column="CURRENCY_CODE" />
<property name="year" column="YEAR"/>
<property name="quarter" column="QUARTER"/>
<property name="costModFlag" type="int" column="COST_MOD_FLAG"/>
<property name="parentId" column="PARENT_ID"/>
<property name="oldParentId" column="OLD_PARENT_ID"/>
<property name="parentIdModFlag" type="int" column="PARENT_ID_MOD_FLAG"/>
<property name="dateIncurred" type="timestamp" column="DATE_INCURRED"/>
<property name="USDAmount" column="USD_AMOUNT" type="double"/>
<property name="isDeleted" type="int" column="IS_DELETED"/>


Reviews and Comments

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

Copyright © www.techfaq360.com 2019

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