This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

@ManyToMany Hibernate Error: “Target Entity is not defined”  RSS feed

 
Greenhorn
Posts: 10
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to create a ManyToMany relation between two Entity-Classes: Produkt.java and Punkt.java. I did it exactly as the hibernate documentation and various tutorials show, and it seems to work, but I get 2 Errors on both of the @ManyToMany-Annontations in both of the Entity-Classes.

The errors are:
"Target entity is not defined"
"The attribute type for a collection mapping must be java.util.Collection, java.util.Set, java.util.List or java.util.Map"

And here are the relevant parts of the code:

Produkt.java



Punkt.java




hibernate.cfg.xml (lies in /src - folder)



As mentioned, this whole construct seems to work - I can run the application, I can create instances of both classes, fill them with data and persist to the database. The only problem now seems to be that the two lines with @ManyToMany - Annotations are marked red in eclipse.

Any help would be greatly appreciated! And please let me know, if more information is needed to solve the problem.
 
Fred Funks
Greenhorn
Posts: 10
Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, after searching and trying things out, I finally got the answers for the both problems:

1. "The target entity is not defined" was caused by the false name of the second table: it should be "@Table(name = "PRODUKT_PUNKT")"


2. "The attribute type for a collection mapping must be java.util.Collection, java.util.Set, java.util.List or java.util.Map" message is an unsolved JBoss bug.

https://issues.jboss.org/browse/JBIDE-16016

It was still there, even when I deleted all the collections and the @ManyToMany parts. It disappeared, when I commented out the constructors. Now I inserted the constructors back again and the errors are not there.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!