Reputation: 20063
In SpringMVC in src/main/resources
I have my hibernate.cfg.xml
I have a class that's my model in src/main/java
org.david.model.UserDetails.java
as pasted below.
@Entity
public class UserDetails {
@Id
private int userId;
private String username;
private String password;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
Whenever I run my project and it hits the code that creates the session I get a
org.hibernate.MappingNotFoundException: resource: org.david.model.UserDetails not found
The line in my hibernate.cfg.xml
that maps to the file is...
<mapping resource="org.david.model.UserDetails"/>
Am I missing something?
Upvotes: 0
Views: 557
Reputation: 26574
I believe your <mapping resource="org.david.model.UserDetails"/>
should point to an hbm.xml file that defines the UserDetails entity. In your case, it looks like you are using annotations to configure the entity, in which case you would want to use something like <mapping class="org.david.model.UserDetails" />
instead of resource=. See http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html/ch01.html
Upvotes: 1