I am a beginner practicing hibernate ORM, I need help in resolving below Exception: Thank you
Entitiy:
package com.ds.supercar.model.usermodel;
public class Address {
private String emailid;
private String mobile;
private String street;
private String city;
private String state;
private String country;
private String pin;
//GETTERS AND SETTERS
public Address() {
// TODO Auto-generated constructor stub
}
public Address(String emailid, String mobile, String street, String city, String state, String country,
String pin) {
super();
this.emailid = emailid;
this.mobile = mobile;
this.street = street;
this.city = city;
this.state = state;
this.country = country;
this.pin = pin;
}
public String getEmailid() {
return emailid;
}
public void setEmailid(String emailid) {
this.emailid = emailid;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getPin() {
return pin;
}
public void setPin(String pin) {
this.pin = pin;
}
}
hbm.xml file
<!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.ds.supercar.model.usermodel.Address" table="supercaraddress" schema="supercar">
<id column="email"/>
<property name="mobile"/>
<property name="street"/>
<property name="city"/>
<property name="state"/>
<property name="country"/>
<property name="pin"/>
</class>
</hibernate-mapping>
hibernate cfg xml:
<!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.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:SYSTEM</property>
<property name="hibernate.connection.username">system</property>
<property name="hibernate.connection.password">admin</property>
<property name="hbm2ddl_auto">create</property>
org.hibernate.dialect.Oracle11gDialect true
Exception:
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly. Initial SessionFactory creation Failed:org.hibernate.MappingException: Error reading resource: com/ds/supercar/resources/mappings/usermodel/address.hbm.xml Exception in thread "main" java.lang.ExceptionInInitializerError at Test.main(Test.java:19) Caused by: org.hibernate.MappingException: Error reading resource: com/ds/supercar/resources/mappings/usermodel/address.hbm.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:449) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1313) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1285) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1267) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1234) at org.hibernate.cfg.Configuration.configure(Configuration.java:1162) at org.hibernate.cfg.Configuration.configure(Configuration.java:1148) at Test.main(Test.java:12) Caused by: org.hibernate.MappingException: must specify an identifier type: com.ds.supercar.model.usermodel.Address at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:354) at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:293) at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235) at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151) at org.hibernate.cfg.Configuration.add(Configuration.java:360) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:397) at org.hibernate.cfg.Configuration.addResource(Configuration.java:446) ... 7 more
Please help me in resolving this problem: