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:
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.
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).
well if you have a composite key u should also have a composite key class
something mapped like this:
@Entity
@IdClass(PK_BP.class)
@Table(name="BP_BIS")
public class BP_BIS implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
private String BP_MODE;
@Id
private String BP_BD;
the composite key class will be like this :
public class PK_BP implements Serializable
{
private static final long serialVersionUID = 1L;
private String BP_MODE;
private String BP_BD;
public PK_BP()
{}
public PK_BP(String bP_MODE, String bP_BD) {
this.BP_MODE = bP_MODE;
this.BP_BD = bP_BD;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With