I'm stumped. I'm setting up a new spring boot project. I've created several entity classes. It is able to create half of the tables in the database fine, so I know for the most part is is able to connect to the database. I've checked and I have the dialect set up in the configuration - I'm using org.hibernate.dialect.MySQLDialect. When I try running the problem, I keep getting a set of errors like this:
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer, symbol varchar(5), primary key (id)) engine=InnoDB' at line 1
I tried checking google and other stackoverflow questions to no avail. Mostly what I found guided me to making sure that I had the right dialect set up, and to avoid reserved keywords which I checked.
here are the other two errors that show up:
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'integer, primary key (id)) type=MyISAM' at line 1
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar(255), clock_in varchar(255), clock_out varchar(255), coin varchar(255), ' at line 1
Edit: Here is the sql that hibernate is generating:
Hibernate: create table record (id integer not null, cash varchar(255), check varchar(255), clock_in varchar(255), clock_out varchar(255), coin varchar(255), primary key (id)) type=MyISAM
create table route (id integer not null, name varchar(100), color integer, driver varchar(255), index integer, primary key (id)) type=MyISAM
create table store (id integer not null, name varchar(100), address varchar(255), index integer, symbol varchar(255), primary key (id)) type=MyISAM
Edit 2 - Here is one of the entity classes that seems to have trouble with the auto table generation:
package org.tampasa.kettles.models;
import javax.persistence.Entity;
@Entity
public class Store extends AbstractEntity{
private String address;
private String symbol;
private int index;
// Constructors
public Store() {
}
// Getters and Setters
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public Integer getIndex() {
return index;
}
public void setIndex(Integer index) {
this.index = index;
}
}
And here is AbstractEntity:
package org.tampasa.kettles.models;
import org.hibernate.validator.constraints.Length;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotBlank;
import java.util.Objects;
@MappedSuperclass
public abstract class AbstractEntity {
@Id
@GeneratedValue
private int id;
@NotBlank(message = "Name must not be blank")
@Length(min = 1, max = 100, message = "Name must be between 1 and 100 characters")
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AbstractEntity that = (AbstractEntity) o;
return id == that.id;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}