Note that there are some explanatory texts on larger screens.

plurals
  1. POHibernate : Reading hbm.xml
    text
    copied!<p>I am following this titorial on roseindia to get basics of Hibernate : "http://roseindia.net/hibernate/hibernate-update.shtml" </p> <p>My code is as below and getting the error for the same. Please assist me to fix it! </p> <p>Java Code: </p> <pre><code>public class UpdateExample { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Session sess = null; try { SessionFactory fact = new Configuration().configure().buildSessionFactory(); sess = fact.openSession(); Transaction tr = sess.beginTransaction(); Insurance ins = (Insurance)sess.get(Insurance.class, new Long(1)); ins.setInsuranceName("Jivan Dhara"); ins.setInvestementAmount(20000); ins.setInvestementDate(new Date()); sess.update(ins); tr.commit(); sess.close(); System.out.println("Update successfully!"); } catch(Exception e){ System.out.println(e.getMessage()); } } </code></pre> <p>} </p> <p>And </p> <pre><code>public class Insurance { private String insuranceName; private double investementAmount; private Date investementDate; public String getInsuranceName() { return insuranceName; } public void setInsuranceName(String insuranceName) { this.insuranceName = insuranceName; } public double getInvestementAmount() { return investementAmount; } public void setInvestementAmount(double investementAmount) { this.investementAmount = investementAmount; } public Date getInvestementDate() { return investementDate; } public void setInvestementDate(Date investementDate) { this.investementDate = investementDate; } </code></pre> <p>}</p> <p>And my contact.hbm.xml :</p> <pre><code> &lt;?xml version="1.0"?&gt; &lt;!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"&gt; &lt;hibernate-mapping&gt; &lt;class name="Contact" table="CONTACT"&gt; &lt;id name="id" type="long" column="ID" &gt; &lt;generator class="assigned"/&gt; &lt;/id&gt; &lt;property name="firstName"&gt; &lt;column name="FIRSTNAME" /&gt; &lt;/property&gt; &lt;property name="lastName"&gt; &lt;column name="LASTNAME"/&gt; &lt;/property&gt; &lt;property name="email"&gt; &lt;column name="EMAIL"/&gt; &lt;/property&gt; &lt;/class&gt; &lt;class name="Book" table="book"&gt; &lt;id name="lngBookId" type="long" column="id" &gt; &lt;generator class="increment"/&gt; &lt;/id&gt; &lt;property name="strBookName"&gt; &lt;column name="bookname" /&gt; &lt;/property&gt; &lt;/class&gt; &lt;class name="Insurance" table="insurance"&gt; &lt;id name="insuranceName" type="String" column="InsuranceName" &gt; /&gt; &lt;/id&gt; &lt;property name="investmentAmount"&gt; &lt;column name="InvestmentAmount" /&gt; &lt;/property&gt; &lt;property name="investmentDate"&gt; &lt;column name="InvestmentDate" /&gt; &lt;/property&gt; &lt;/class&gt; &lt;/hibernate-mapping&gt; </code></pre> <p>And the error i am getting is: </p> <p>"Error reading resource: contact.hbm.xml" </p> <p>Also I have created db table by name Insurance with those column fields. </p> <p>Thanks<br> Sneha</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload