I'm using JPA for the first time and still got some problems with it. Meanwhile I get connected to my database and JPA is creating not already existing Tables automatically.
My problem is that the created tables wont define table columns as Foreign Key which I marked as such.
Here is how I declare a Foreign Key in my program:
@ManyToOne(optional = false)
@JoinColumn(nullable = false, name = "ATT_ID")
private Attribute att;
As database I use MySQL community server 5.7.19 which shows me this as DDL for the newly created Table
CREATE TABLE `TABLE` (
`ID` int(11) NOT NULL,
`FOREIGN_ID` int(11) NOT NULL,
`FOREIGN_ID2` int(11) NOT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `STUFF` (`ID`),
KEY `STUFF` (`FOREIGN_ID`),
KEY `STUFF` (`FOREIGN_ID2`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
I changed some things for security reasons, but as you can see, the Columns are clearly not marked as foreign keys.
I don't know what I am doing wrong, I searched the web for explanations, but every thread etc. I red just said to use the Annotations I am already using.
Does anyone know what I am doing wrong?
Thanks in advance