0

I have been trying to create a program using vaadin, spring boot and flyway. However when I try to access the program JPA is not reading the correct database. Here is the example I have been following: https://github.com/mstahv/spring-data-vaadin-crud

GameTemplate.java

@Entity
@Table(name = "GameTemplate")
public class GameTemplate implements Serializable {
private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;

@NotNull(message = "Part number is required")
private String partNum;

private String gameName;
private Double gameCost;
private Double ticketCost;
private Integer numTickets;
private Integer idealGross;
private Integer idealPrizes;
private Integer idealNet;
//omitted

public GameTemplate(){
    //JPA
}
//getters/setters

GameTemplateRepo.java

public interface GameTemplateRepository extends JpaRepository<GameTemplate,    Long> {

List<GameTemplate> findAllBy(Pageable pageable);

List<GameTemplate> findByPartNumLikeIgnoreCase(String partnumFilter);
}

resources/db.migration/V1__Initial_Schema.sql

CREATE TABLE GameTemplate (
`id` bigint auto_increment,
`partNum` varchar(12) NOT NULL,
`gameName` varchar(50) DEFAULT NULL,
`gameCost` double DEFAULT '0',
`ticketCost` double DEFAULT NULL,
`numTickets` int(11) DEFAULT NULL,
`idealGross` mediumint(9) DEFAULT NULL,
`idealPrizes` mediumint(9) DEFAULT NULL,
`idealNet` mediumint(9) DEFAULT NULL,
//omitted, inserted some data as well.

Stack:

2016-12-07 20:14:25.818  INFO 18236 --- [  restartedMain] o.f.core.internal.util.VersionPrinter    : Flyway 3.2.1 by Boxfuse
2016-12-07 20:14:25.946  INFO 18236 --- [  restartedMain] o.f.c.i.dbsupport.DbSupportFactory       : Database: jdbc:h2:mem:testdb (H2 1.4)
2016-12-07 20:14:26.057  INFO 18236 --- [  restartedMain] o.f.core.internal.command.DbValidate     : Validated 1 migration (execution time 00:00.082s)
2016-12-07 20:14:26.066  INFO 18236 --- [  restartedMain] o.f.c.i.metadatatable.MetaDataTableImpl  : Creating Metadata table: "PUBLIC"."schema_version"
2016-12-07 20:14:26.080  INFO 18236 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Current version of schema "PUBLIC": << Empty Schema >>
2016-12-07 20:14:26.080  INFO 18236 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Migrating schema "PUBLIC" to version 1 - Initial Schema
2016-12-07 20:14:26.095  INFO 18236 --- [  restartedMain] o.f.core.internal.command.DbMigrate      : Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.030s).

Everything appears to be good but when accessing on localhost:

2016-12-07 20:14:29.680 ERROR 18236 --- [nio-8090-exec-5] o.h.engine.jdbc.spi.SqlExceptionHelper   : Table "GAME_TEMPLATE" not found; SQL statement:

Where in the world is it getting "GAME_TEMPLATE"?

Switcher
  • 112
  • 12

1 Answers1

0

This is because Spring by default uses org.springframework.boot.orm.jpa.SpringNamingStrategy which splits camel case names with underscore. See this for more help.

Or you can change the table name in the file V1__Initial_Schema.sql to Game_Template

Community
  • 1
  • 1
Nico
  • 201
  • 3
  • 11