Hibernate Entities generated using IntelliJ have no Foreign Keys generated
Answered
I have a database created in MariaDB called persistence with two related tables employee user, create a project with IntelliJ IDEA 2016.2.3 using Hibernate more JPA, achievement connect to the database but when making the mapping to the database and generate entities in these models have no foreign key relationship. But when revizar diagram IntelliJ Idea generated in the relationship if recognized. Someone can tell me is happening.
Adjunct source for error checking code.
https://www.dropbox.com/s/c2oqwc6vbu29xs7/JPAexample.zip?dl=0
Thank you.
Please sign in to leave a comment.
Thanks for sample project. Works for me when I'm generating the models from my local MySQL database:
Do you see foreign key constraints in Database tool window? Do you see them in Generate Persistence Mapping dialog (make sure you have check Show default relationship check box)? Are there any errors in idea.log when you are generating the mapping?
What database version and jdbc driver you use (please attach output from Test Connection button for the data source)?
The version of IntelliJ IDEA 2016.2.3
I have done all the steps that you describe and corrected some errors that had at the time of mapping, the problem I have now is that when you make an inquiry by the console JPA-Console throws me these warnings:
jpa-ql> select EmpleadoEntity.apellido from EmpleadoEntity


[09/09/2016 11:58:53] EmpleadoEntity is not mapped [select EmpleadoEntity.apellido from EmpleadoEntity]
jpa-ql> select EmpleadoEntity.apellido from employee
[09/09/2016 11:59:39] employee is not mapped [select EmpleadoEntity.apellido from employee]
jpa-ql> select EmpleadoEntity.apellido from models.EmpleadoEntity
[09/09/2016 12:01:04] models.EmpleadoEntity is not mapped [select EmpleadoEntity.apellido from models.EmpleadoEntity]
jpa-ql> select EmpleadoEntity.apellido from models.EmpleadoEntity
[09/09/2016 12:02:08] models.EmpleadoEntity is not mapped [select EmpleadoEntity.apellido from models.EmpleadoEntity]
jpa-ql> select EmpleadoEntity.apellido from EmpleadoEntity
[09/09/2016 12:03:55] EmpleadoEntity is not mapped [select EmpleadoEntity.apellido from EmpleadoEntity]
<code>
</code>
<code>
<code>
</code>
https://www.dropbox.com/s/c2oqwc6vbu29xs7/JPAexample.zip?dl=0
Keep in mind that the pablabra HibernatePersistence org.hibernate.ejb.HibernatePersistence is crossed out and I do not understand why this?
That means it's deprecated. Use instead: