1

I have some domain object in my webapp named of Site. Site would be contains list of IP addresses, that is

@Entity
class Site {

    ...

    @ManyToMany(fetch=FetchType.LAZY)
    public Set<String> ips= new HashSet<String>();

    ...

}

But hibernate is down when I try to start webapp with error:

Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: my.webapp.Site.ips[java.lang.String]

What's the problem?

1 Answer 1

1

You cannot use relational annotations (i.e. @ManyToMany) if you don't have a relationship with an Entity. If you have basic type (as in this case - String) you should use @ElementCollection

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.