2

JPA Tools -> Generate Entities from Tables... results in duplicate fields:

dups

Predictably this results in this:

dups

Not shown are all the duplicated getters and setters. Deleting them is a pain, even for a small class like this.

I cannot see any easy option to fix this. Does anyone have any ideas why it's happening? Thanks in advance.

JL_SO
  • 1,742
  • 1
  • 25
  • 38
  • Which database are you using? – Simon Martinelli Aug 20 '18 at 17:33
  • I'm using MySQL – JL_SO Aug 20 '18 at 18:10
  • and which Eclipse version? – Simon Martinelli Aug 20 '18 at 18:53
  • Version: Photon Release (4.8.0) Build id: 20180619-1200 – JL_SO Aug 20 '18 at 18:58
  • My suspicion is that in your DB you have the same table in TWO schemas/users. Could it be? – Little Santi Aug 20 '18 at 23:11
  • Interesting idea, thanks, but no, that's not the case. https://i.stack.imgur.com/T9QIr.png You must be on the right lines though. It's got to be something like that. It would be nice to know how to "see" what eclipse is actually doing when you click these bloody buttons. – JL_SO Aug 20 '18 at 23:45
  • I tried to reproduce this issue but for me everything works find. I see that there is a second schema with the suffix _jpa. Could this be the problem? – Simon Martinelli Aug 21 '18 at 06:28
  • Neither is there a **view** named "course"? – Little Santi Aug 21 '18 at 16:01
  • @simon-martinelli, thanks for the suggestion but it's a different schema, in mysql that means a different database; it has a different name. That cannot plausibly be the explanation. Of course, without seeing the code, it's impossible to know, but having to delete the schema just to prove it's not the cause seems to be going too far I think. – JL_SO Aug 21 '18 at 16:08
  • @LittleSanti no there is no view called "course". – JL_SO Aug 21 '18 at 16:08

2 Answers2

4

This is true for mysql. I had three identical schemas with the same user table on mysql database instance. The entity created by the JPA Tools plugin had multiple fields with same name mapped to the multiple user tables in various schemas. Once I deleted all but one schema on the database, the tool retrieved correct list of fields that mapped to columns on the table

dparikh
  • 41
  • 2
2

I had the same issue. I just renamed the other table in another schema. It seems that the Generate Entities from Table in Eclipse for a MySQL database looks for all tables with the same name no matter the schema.

Jose Mena
  • 91
  • 9