0

I have some classes in my java spring boot project. I use jpa and xampp for localhost. All the Entity classes work and create tables for every @Entity class. But this class does not work. Why?

@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
public class Match {
    @Id
    private String matchId;
    @Enumerated
    private MatchType matchType;
}
Mark
  • 5,089
  • 2
  • 20
  • 31
Kamrul Hasan
  • 69
  • 3
  • 11
  • What the difference between this class and a class that works? – XtremeBaumer Oct 23 '18 at 13:03
  • `Match` is a reserved keyword in MySQL, so possibly it doesn't allow a table by that name to be created. – TiiJ7 Oct 23 '18 at 13:10
  • I guess Matnh is reserved and also check ddl-auto: true in your properties – Stimpson Cat Oct 23 '18 at 13:12
  • Create another entity named Where, see if it's working. –  Oct 23 '18 at 13:19
  • i even dont know what's the reason. every classes with @Entity tag creates table in databse but this doesnot – Kamrul Hasan Oct 23 '18 at 13:22
  • spring.datasource.username=root spring.datasource.password= spring.datasource.url=jdbc:mysql://localhost/game_db spring.jpa.hibernate.ddl-auto=update spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect spring.jpa.show-sql=true – Kamrul Hasan Oct 23 '18 at 13:24
  • what does your DEBUGGING tell you? like looking in the LOG of your chosen JPA provider? You have looked? –  Oct 23 '18 at 13:59
  • Are the other classes listed in the persistence.xml? How are they added to the persistence unit? Check that this one is also, either within the persistence.xml or within the same directory structure during runtime. – Chris Oct 23 '18 at 15:56
  • https://github.com/KamrulHasan-Seu/Research-Methodology/tree/master/Game_Backend/src/main Here my repository.I changed that class name but it does not crete any table and make some error when i run this program. Anyone help pls. – Kamrul Hasan Oct 23 '18 at 17:51

1 Answers1

1

Try this:

@AllArgsConstructor
@NoArgsConstructor
@Data
@Entity
@Table(name = "\"Match"\")
public class Match {
    @Id
    private String matchId;
    @Enumerated
    private MatchType matchType;
}

More general, if you set

hibernate.globally_quoted_identifiers=true

every identifier gets quoted.