JPA @Table ignored
Hello,
I am new to IDEA. I've successfully imported a project and built it with Maven. The IDE automagically found the JPA resources and connected to the DB. This is just awesome. :)
However, it seems like the entities are validated against the wrong table. Let me explain:
- In the DB, (a somewhat messy dev database), there is a table named MyEntity and another called TBL_MY_ENTITY.
- In the code, a class is called MyEntity.
- In MyEntity, there is an anotation @Table( name = "TBL_MY_ENTITY")
The validation is done against the table named MyEntity, and I expected it to be done against TBL_MY_ENTITY since it's the one specified in the @Table annotation.
I realize this situation is not really typical, but it still seems wrong to me.
Thanks for your help!
Sébastien
Please sign in to leave a comment.
Hello.
Can't reproduce the problem. How do you see the validation is done against wrong table? Can you attach a small sample project?
Thank you,
Alexander.
Since the two tables do not have the same columns, I can see that the validation is done on the "wrong" table by changing the @Column(name = "XY") annotation and seeing that the validation is "OK" on some columns and "KO" on others.
I'll try to extract a reproducer but since it's in a pretty big project, it's not going to be trivial.
Thanks for your support!
Sébastien
Hi,
I've managed to extract one class, along with the DDL of the two tables that are in conflict.
To reproduce the bug, I hit ctrl-space in the Account class, at right after the double quote here:
@Column(name = "ACCOUNTNUMBER")
This pops up a list of possible matches for the column, all belonging to the Account table, not the TBL_BANK_ACCOUNT one.
Hope this helps...
Sébastien
Attachment(s):
JPATableBugReproducer.zip
Thanks a lot. Reproduced and created: http://youtrack.jetbrains.com/issue/IDEA-122521
For me the workaround is adding the class to persistent unit via <class> element, not with mapping file.
Regards,
Alexander.
Hi,
Thanks for your help.
I'd like to follow the bug, but my account here seems not to work on youtrack.jetbrains.com... do I have to create a separate account??
Sébastien
Unfortunately, yes, you do. Or you can use so called JetBrains Account (JBA) if you have one.
Thank you,
Alexander.