spring-in-action-5-samples
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)
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.
thanks you
in my case , you also need spring.datasource.initialization-mode=always spring.jpa.hibernate.ddl-auto=none
to have the data.sql loaded
thank you