I have many JPA entity classes of the general form:
@Entity
@Table(name = "MY_TABLE", catalog = "", schema = "VBMSUI")
@NamedQueries({...})
public class MyEntity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "ID")
@GeneratedValue(strategy=GenerationType.SEQUENCE,
generator="MY_TABLE_ID_SEQ")
@SequenceGenerator(name="MY_TABLE_ID_SEQ",
sequenceName = "MY_TABLE_ID_SEQ")
private BigDecimal id;
...
}
IntelliJ's inspection facility underlines "id" in red, and provides the message - "more than one attribute configured for field 'id'".
There are no other attributes in the class identifed as an id. There is a getter and a setter for "id", but they have no annotations. BTW, the code for the entity class was generated by NetBeans, and it seems to work.
What is happening, and how can I correct it?
This seems to happen because you have both @Id
and @Basic
annotations on the same attribute (quick fixes suggest removing either one of them). I'm no expert in JPA, but it looks valid to me, so perhaps it is a bug in IntelliJ's inspection, which should be reported in their bugtracker.
It appears that this is a bug. It has been reported as such here: https://youtrack.jetbrains.com/issue/IDEA-129147 You can up-vote it if you wish to see a resolution.
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