Spring Boot isn't creating one of my tables

I'm using Spring Boot for first time, and I don't know why spring dont create me a table which is written like other tables on my project. The table is the following:

package org.springframework.cluedo.user;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cluedo.card.Card;
import org.springframework.cluedo.game.Game;
import org.springframework.cluedo.model.BaseEntity;

import lombok.Getter;
import lombok.Setter;

@Entity
@Getter
@Setter
@Table(name = "user_games")
public class UserGame extends BaseEntity{
    @Column
    private Integer order;

    @Min(0)
    @Value("${some.key:0}")
    private Integer accusationsNumber;
    
    @NotNull
    private Boolean isAfk;
    
    @NotNull
    private SuspectType suspect;

    @ManyToOne(optional = false)
    @JoinColumn(name="user_id")
    private User user;

    @ManyToOne
    @JoinColumn(name="game_id")
    private Game game;

    @ManyToMany
    @JoinTable(name="user_cards")
    private Set<Card> cards;
}

Also Spring created user_cards, which is in this class, but not the user_games table

When I consult h2-console, all tables appear but this no.

Upvotes: 0

Views: 38

Answers (1)

After searching into my code and test many things, I discovered that SQL doesn't permit parameters called order. I modified the order to orderUser and finally I have my table. For test this, I tried to manually create the table and "Identifier spected" error appeared, and a parameter order[*] appeared.

CREATE TABLE user_games(id integer, orderPlayer integer ,accusations_number integer ,is_afk boolean ,suspect varchar(60),user_id integer,game_id integer);
Syntax error in SQL statement "CREATE TABLE USER_GAMES(ID INTEGER, ORDER[*] INTEGER ,ACCUSATIONS_NUMBER INTEGER ,IS_AFK BOOL ,SUSPECT VARCHAR(60),USER_ID INTEGER,GAME_ID INTEGER)"; expected "identifier"; SQL statement: 

Upvotes: 1

Related Questions