spring-in-action-5-samples icon indicating copy to clipboard operation
spring-in-action-5-samples copied to clipboard

chapter 3 the "data.sql" file is missing and should annotate Type type with @Enumerated(EnumType.STRING)

Open Sammygracezhu opened this issue 5 years ago • 3 comments

chapter 3 in tacos-jpa, the "data.sql" file is missing. I can not get any data about ingredients. Then I put the 'data.sql' file in 'src/main/resources', it worked. Also I get error "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.jdbc.datasource.init.ScriptStatementFailedException: Failed to execute SQL script statement #6 of URL [file:/home/zhu/NetBeansProjects/Jpa-Taco-cloud-chapter3/target/classes/data.sql]: insert into Ingredient (id, name, type) values ('FLTO', 'Flour Tortilla', 'WRAP'); nested exception is org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "'WRAP' (INGREDIENT: ""TYPE"" INTEGER)"; SQL statement:"

After I annotated Type type with @Enumerated(EnumType.STRING) in Ingredient class, it worked.

Sammygracezhu avatar Dec 14 '19 14:12 Sammygracezhu

thanks you

khanhtran94 avatar Apr 16 '20 17:04 khanhtran94

in my case , you also need spring.datasource.initialization-mode=always spring.jpa.hibernate.ddl-auto=none to have the data.sql loaded

dassio avatar Aug 02 '20 12:08 dassio

thank you

hobossa avatar May 17 '22 22:05 hobossa