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 !!!

Hibernate setup using .cfg.xml file ?

!!!Answer!!!- From Technical Expert

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"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory
name="java:hibernate/SessionFactory">
<!-- 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">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- mapping files -->
<mapping resource="org/hibernate/auction/Cost.hbm.xml"/>
</session-factory>
</hibernate-configuration>
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()
.configure("catdb.cfg.xml")
.buildSessionFactory();

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

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

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

<id name="id" column="ID">
</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"/>
</class>

</hibernate-mapping>

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


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


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


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


Answered By : null Replied Date : Apr 29 2014
Answer :


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


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


Answered By : null Replied Date : Nov 5 2014
Answer :


Answered By : null Replied Date : Dec 19 2014
Answer :


Answered By : null Replied Date : Jan 24 2015
Answer :


Answered By : null Replied Date : Oct 28 2015
Answer :


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


Answered By : null Replied Date : Sep 29 2016
Answer :


Answered By : null Replied Date : Sep 29 2016
Answer :


Answered By : null Replied Date : Sep 29 2016
Answer :


Answered By : null Replied Date : Oct 7 2016
Answer :


Answered By : null Replied Date : Oct 7 2016
Answer :


Answered By : null Replied Date : Oct 7 2016
Answer :


Answered By : null Replied Date : Oct 7 2016
Answer :


Answered By : null Replied Date : Oct 7 2016
Answer :


Answered By : null Replied Date : Dec 12 2016
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