0

I'm trying to include an enum field to my entity using @Enumerated, Here is my code :

@Entity
public class Frequency extends AbstractModel {
	
	@Column(nullable = true)
	@Enumerated(EnumType.STRING)
	protected DayOfWeek dayOfWeek;

	@Enumerated(EnumType.STRING)
	protected IntervalEnum interval;
}

But when building my project, I get the error :

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'interval varchar(255), primary key (id)) engine=MyISAM' at line 1

It's the enum which is responsible of the error, but why ?

public enum IntervalEnum {
	D,
	W,
	M;
}

I'm using Hibernate 5.2.16 + MySQL 5.7 + Spring boot 1.5.12

Thank you

1 Answer 1

2

Interval is a reserved keyword for mysql

Use @Column to specify a valid name on

protected IntervalEnum interval;

Sign up to request clarification or add additional context in comments.

2 Comments

ok isn't interval a protected mysql keyword ? Can you try to rename it or put the @Column with other name ?
You are right, Interval is a reserved keyword. I changed the name of the field and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.