JPA tool - Generate entities from tables with foreign keys mapped with non-primary key

300 Views Asked by At

I have a MySQL database on which I want to generate entities with Dali JPA Tool built into Eclipse. The database is not mine, and I prefer not to ask for the change of architecture.

The problem exists when I create entities because a table has a foreign key that is mapped to a column in another table that is not a primary key. I have noticed that for this reason the entity of this table is not created by the tool (but it's added in persistence.xml).

Is there a way to generate the entity without having to change the database architecture?

Thanks a lot for every possible idea.

PS: I'm not a database expert, but is it ok to create foreign keys that are mapped to columns that are not primary keys?

0

There are 0 best solutions below