Eclipse error when using multiple @Id for composite primary keys

Mateus Viccari picture Mateus Viccari · Jan 11, 2014 · Viewed 13.7k times · Source

in my Model project (it only has the persistent classes, aka java beans) i have a class which has a composite primary key. To map this, i have used two @Id in my class. Before hibernate 4 it was not possible but now it is Ok. So, the problem is, eclipse is showing an error in this class, saying that it should be done in the old way. Like this:

False error

As i said, it is a false error, because the code works fine if i execute it. I have JBoss Tools plugin installed on eclipse, but i don't know if the errors is being caused by it or by eclipse.

Anyone know how to solve this issue? Not that it is preventing me from executing the app, but it is an annoying thing to have the error being always shown.

--- EDIT ---

So, now i know the problem is on JBoss Tools because i deactivated the JPA facet on the project and the error have stopped. But i wish i could use the facilities that JBoss Tools gives, so... no solution yet.

Answer

petroman picture petroman · Jan 9, 2015

Well it's almost a year late, but I just came across this problem myself today :-)

You can turn off this error in Eclipse. Go to

Preferences->Java Persistence->JPA->Errors/Warnings

Under the Type section look for the category "ID class must be used when multiple ID mappings defined." and change it from Error to Ignore (or whatever severity you want to give it).