habuma / spring-in-action-6-samples

Sample code from Spring in Action 6
486 stars 342 forks source link

Define Primary Key for Ingredient #8

Closed mrigankvallabh closed 2 years ago

mrigankvallabh commented 2 years ago

In Chapter 3 code, the primary key has to be added else it fails create table if not exists Ingredient ( id varchar(4) not null primary key, name varchar(25) not null, type varchar(10) not null );

Caused by: org.springframework.jdbc.datasource.init.ScriptStatementFailedException:
Failed to execute SQL script statement #6 of URL [file:/C:/Users/mrigank.ballabh/source/repos/spring-in-action-6-samples/ch03/tacos-jdbctemplate/target/classes/schema.sql]: alter table Ingredient_Ref add foreign key (ingredient) references Ingredient(id); nested exception is org.h2.jdbc.JdbcSQLSyntaxErrorException: Constraint "PRIMARY KEY | UNIQUE (ID)" not found;
mrigankvallabh commented 2 years ago

This issue has already been raised https://github.com/habuma/spring-in-action-6-samples/issues/6

AndyLau223 commented 2 years ago

Your approach is working! Thank you very much.