• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Could not read mappings from resource(Mapping issue)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Following error i am getting in my hibernate program...attaching errors,hbm file and cfg

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
org.hibernate.MappingException: Could not read mappings from resource: com/jlcindia/hibernate/Student.hbm.xml
at org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1310)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1296)
at com.jlcindia.hibernate.CHibernateUtil.<clinit>(CHibernateUtil.java:10)
at com.jlcindia.hibernate.CLab4Client.main(CLab4Client.java:12)
Caused by: org.hibernate.PropertyNotFoundException: field not found: qualification
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:97)
at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:104)
at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:112)
at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:89)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:77)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2138)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2115)
at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2005)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:368)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:282)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:153)
at org.hibernate.cfg.Configuration.add(Configuration.java:386)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:427)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:482)
... 8 more
java.lang.NullPointerException
at com.jlcindia.hibernate.CLab4Client.main(CLab4Client.java:13)



--------------------------------------------------------------------------------------------

-----------------------------------------------------------------------
my cfg code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">altruist</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/jlcdb1</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="myeclipse.connection.profile">mysqlDriver</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="show_sql">true</property>

<property name="hbm2ddl.auto"> update</property>
<mapping resource="com/jlcindia/hibernate/Student.hbm.xml"/>
</session-factory>
</hibernate-configuration>
-----------------------------------------------------------------------------------------------------------
using a package:com.jlcindia.hibernate and kept hbm in the same pkg and cfg in src directory,still facing problem while running the code..please anyone solve this issue!
if you need hbm.xml then here it is:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.jlcindia.hibernate">
<class name="Student" table="mystudents">
<id name="sid" column="sid" type="int">
<generator class="increment"/>
</id>
<property name="sname" />
<property name="dob" />
<property name="qualification"/>

<array name="courses" table="courses">
<key column="sid" />
<index column="idx" />
<element column="ename" type="String" />
</array>

<list name="emails" table="emails">
<key column="sid" />
<index/>
<element column="emailID" type="String" />
</list>

<bag name="marks" table="marks">
<key column="sid" />
<element column="marks" type="int" />
</bag>

<set name="phones" table="phones">
<key column="sid" />
<element column="phoneNo" type="long" />
</set>

<map name="refs" table="refs">
<key column="sid" />
<index column="rname" type="String"/>
<element column="rphone" type="long" />
</map>
</class>
<filter-def name="titleFilter">
<filter-param name="titleParam" type="string" />
</filter-def>

</hibernate-mapping>
----------------------------------------------------------------------------------------------
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your Student.java code here. I suspect, the below property is missing in the java class.

<property name="qualification"/>
 
Ranendra Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for replying Reddy Prashanth !here is my Student.java
package com.jlcindia.hibernate;

import java.util.*;

public class Student {

private int sid;
private String sname;

private String dob;
private String qualifiaction;

private String[]courses;

private List<String> emails;

private List<Integer> marks;


private Set<Long> phones;

private Map<String, Long> refs;

public Student(String sname, String dob, String qualifiaction,
String[] courses, List<String> emails, List<Integer> marks,
Set<Long> phones, Map<String, Long> refs) {
super();
this.sname = sname;
this.dob = dob;
this.qualifiaction = qualifiaction;
this.courses = courses;
this.emails = emails;
this.marks = marks;
this.phones = phones;
this.refs = refs;
}

public int getSid() {
return sid;
}

public void setSid(int sid) {
this.sid = sid;
}

public String getSname() {
return sname;
}

public void setSname(String sname) {
this.sname = sname;
}

public String getDob() {
return dob;
}

public void setDob(String dob) {
this.dob = dob;
}

public String getQualifiaction() {
return qualifiaction;
}

public void setQualifiaction(String qualifiaction) {
this.qualifiaction = qualifiaction;
}

public String[] getCourses() {
return courses;
}

public void setCourses(String[] courses) {
this.courses = courses;
}

public List<String> getEmails() {
return emails;
}

public void setEmails(List<String> emails) {
this.emails = emails;
}

public List<Integer> getMarks() {
return marks;
}

public void setMarks(List<Integer> marks) {
this.marks = marks;
}

public Set<Long> getPhones() {
return phones;
}

public void setPhones(Set<Long> phones) {
this.phones = phones;
}

public Map<String, Long> getRefs() {
return refs;
}

public void setRefs(Map<String, Long> refs) {
this.refs = refs;
}



}
 
Reddy Prashanth
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the difference .. both are not same

private String qualifiaction;

<property name="qualification"/>


 
Ranendra Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so silly mistake done by me...hey thanks a ton!but other issue is:
(org.hibernate.MappingException: Could not determine type for: String, for columns: [org.hibernate.mapping.Column(emailID)])
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic