0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.