Spring/Hibernate: Table is not created - “Error executing DDL …”
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
In my structure, each "Task" has OneToOne relation with one "Problem" and each "Problem" has OneToOne with a "Solution". A "Solution" has a list of "Items".
I cannot find a way to make it work. when hibernates starts I have this exception and the table "Item" is not created.
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table item add constraint FKmkmqr7wiqxa0t51p9k4c9kbkb foreign key (solution_id) references solution (id)" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:310) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.3.RELEASE.jar:5.1.3.RELEASE]
The code is below (omitting getters and setters).
Task
@Entity
@JsonIgnoreProperties(ignoreUnknown = true,
value = {"id"})
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@JsonProperty("task")
private String taskName;
private String status;
private Timestamps timestamps;
@OneToMany(mappedBy = "task", cascade = {CascadeType.ALL})
private List<Problem> problem;
public Task(){
}
}
Problem
@Entity
public class Problem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer capacity;
@ElementCollection
@CollectionTable(name="weights",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="weights")
private List<Integer> weights;
@ElementCollection
@CollectionTable(name="_values",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="_values")
private List<Integer> values;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Task task;
@OneToOne
private Solution solution;
}
Solution:
@Entity
public class Solution {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch=FetchType.LAZY)
@JsonIgnore
private Task task;
@OneToOne(cascade = {CascadeType.ALL})
private Problem problem;
@OneToMany
private List<Item> items;
}
Item:
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer values;
private Integer weight;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Solution solution;
}
java mysql hibernate spring-boot jpa
add a comment |
In my structure, each "Task" has OneToOne relation with one "Problem" and each "Problem" has OneToOne with a "Solution". A "Solution" has a list of "Items".
I cannot find a way to make it work. when hibernates starts I have this exception and the table "Item" is not created.
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table item add constraint FKmkmqr7wiqxa0t51p9k4c9kbkb foreign key (solution_id) references solution (id)" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:310) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.3.RELEASE.jar:5.1.3.RELEASE]
The code is below (omitting getters and setters).
Task
@Entity
@JsonIgnoreProperties(ignoreUnknown = true,
value = {"id"})
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@JsonProperty("task")
private String taskName;
private String status;
private Timestamps timestamps;
@OneToMany(mappedBy = "task", cascade = {CascadeType.ALL})
private List<Problem> problem;
public Task(){
}
}
Problem
@Entity
public class Problem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer capacity;
@ElementCollection
@CollectionTable(name="weights",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="weights")
private List<Integer> weights;
@ElementCollection
@CollectionTable(name="_values",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="_values")
private List<Integer> values;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Task task;
@OneToOne
private Solution solution;
}
Solution:
@Entity
public class Solution {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch=FetchType.LAZY)
@JsonIgnore
private Task task;
@OneToOne(cascade = {CascadeType.ALL})
private Problem problem;
@OneToMany
private List<Item> items;
}
Item:
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer values;
private Integer weight;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Solution solution;
}
java mysql hibernate spring-boot jpa
you did not mentioned the foreign key name. Add@JoinColumn(name = "solution_id")
annotation atItem
table after@ManyToOne
annotation.
– Erfan Ahmed
Jan 3 at 4:20
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33
add a comment |
In my structure, each "Task" has OneToOne relation with one "Problem" and each "Problem" has OneToOne with a "Solution". A "Solution" has a list of "Items".
I cannot find a way to make it work. when hibernates starts I have this exception and the table "Item" is not created.
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table item add constraint FKmkmqr7wiqxa0t51p9k4c9kbkb foreign key (solution_id) references solution (id)" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:310) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.3.RELEASE.jar:5.1.3.RELEASE]
The code is below (omitting getters and setters).
Task
@Entity
@JsonIgnoreProperties(ignoreUnknown = true,
value = {"id"})
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@JsonProperty("task")
private String taskName;
private String status;
private Timestamps timestamps;
@OneToMany(mappedBy = "task", cascade = {CascadeType.ALL})
private List<Problem> problem;
public Task(){
}
}
Problem
@Entity
public class Problem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer capacity;
@ElementCollection
@CollectionTable(name="weights",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="weights")
private List<Integer> weights;
@ElementCollection
@CollectionTable(name="_values",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="_values")
private List<Integer> values;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Task task;
@OneToOne
private Solution solution;
}
Solution:
@Entity
public class Solution {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch=FetchType.LAZY)
@JsonIgnore
private Task task;
@OneToOne(cascade = {CascadeType.ALL})
private Problem problem;
@OneToMany
private List<Item> items;
}
Item:
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer values;
private Integer weight;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Solution solution;
}
java mysql hibernate spring-boot jpa
In my structure, each "Task" has OneToOne relation with one "Problem" and each "Problem" has OneToOne with a "Solution". A "Solution" has a list of "Items".
I cannot find a way to make it work. when hibernates starts I have this exception and the table "Item" is not created.
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table item add constraint FKmkmqr7wiqxa0t51p9k4c9kbkb foreign key (solution_id) references solution (id)" via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applyForeignKeys(AbstractSchemaMigrator.java:433) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:249) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:310) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) [hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.1.3.RELEASE.jar:5.1.3.RELEASE]
The code is below (omitting getters and setters).
Task
@Entity
@JsonIgnoreProperties(ignoreUnknown = true,
value = {"id"})
public class Task {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@JsonProperty("task")
private String taskName;
private String status;
private Timestamps timestamps;
@OneToMany(mappedBy = "task", cascade = {CascadeType.ALL})
private List<Problem> problem;
public Task(){
}
}
Problem
@Entity
public class Problem {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer capacity;
@ElementCollection
@CollectionTable(name="weights",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="weights")
private List<Integer> weights;
@ElementCollection
@CollectionTable(name="_values",
joinColumns=@JoinColumn(name="problem_id"))
@Column(name="_values")
private List<Integer> values;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Task task;
@OneToOne
private Solution solution;
}
Solution:
@Entity
public class Solution {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch=FetchType.LAZY)
@JsonIgnore
private Task task;
@OneToOne(cascade = {CascadeType.ALL})
private Problem problem;
@OneToMany
private List<Item> items;
}
Item:
@Entity
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private Integer values;
private Integer weight;
@ManyToOne(fetch=FetchType.LAZY, cascade = {CascadeType.ALL})
@JsonIgnore
private Solution solution;
}
java mysql hibernate spring-boot jpa
java mysql hibernate spring-boot jpa
edited Jan 5 at 21:03
halfer
14.7k759116
14.7k759116
asked Jan 3 at 4:11
Thadeu Antonio Ferreira MeloThadeu Antonio Ferreira Melo
306414
306414
you did not mentioned the foreign key name. Add@JoinColumn(name = "solution_id")
annotation atItem
table after@ManyToOne
annotation.
– Erfan Ahmed
Jan 3 at 4:20
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33
add a comment |
you did not mentioned the foreign key name. Add@JoinColumn(name = "solution_id")
annotation atItem
table after@ManyToOne
annotation.
– Erfan Ahmed
Jan 3 at 4:20
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33
you did not mentioned the foreign key name. Add
@JoinColumn(name = "solution_id")
annotation at Item
table after @ManyToOne
annotation.– Erfan Ahmed
Jan 3 at 4:20
you did not mentioned the foreign key name. Add
@JoinColumn(name = "solution_id")
annotation at Item
table after @ManyToOne
annotation.– Erfan Ahmed
Jan 3 at 4:20
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33
add a comment |
1 Answer
1
active
oldest
votes
The problem was with having a variable/field called "values". "values" is a reserved word in Mysql, so the query generated by Spring JPA is invalid.
One solution is simply to change the variable "values" to "_values" or add the annotation @Column(name = "_value")
if you need to keep the name in the code the same.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016250%2fspring-hibernate-table-is-not-created-error-executing-ddl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The problem was with having a variable/field called "values". "values" is a reserved word in Mysql, so the query generated by Spring JPA is invalid.
One solution is simply to change the variable "values" to "_values" or add the annotation @Column(name = "_value")
if you need to keep the name in the code the same.
add a comment |
The problem was with having a variable/field called "values". "values" is a reserved word in Mysql, so the query generated by Spring JPA is invalid.
One solution is simply to change the variable "values" to "_values" or add the annotation @Column(name = "_value")
if you need to keep the name in the code the same.
add a comment |
The problem was with having a variable/field called "values". "values" is a reserved word in Mysql, so the query generated by Spring JPA is invalid.
One solution is simply to change the variable "values" to "_values" or add the annotation @Column(name = "_value")
if you need to keep the name in the code the same.
The problem was with having a variable/field called "values". "values" is a reserved word in Mysql, so the query generated by Spring JPA is invalid.
One solution is simply to change the variable "values" to "_values" or add the annotation @Column(name = "_value")
if you need to keep the name in the code the same.
answered Jan 3 at 13:01
Thadeu Antonio Ferreira MeloThadeu Antonio Ferreira Melo
306414
306414
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016250%2fspring-hibernate-table-is-not-created-error-executing-ddl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you did not mentioned the foreign key name. Add
@JoinColumn(name = "solution_id")
annotation atItem
table after@ManyToOne
annotation.– Erfan Ahmed
Jan 3 at 4:20
It doesn`t work. Same error.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:23
by same error you mean - the error is still for the item table?
– Erfan Ahmed
Jan 3 at 4:28
The error was the same. I just figured out. It was the variable "values". It generates a syntax error in mysql.
– Thadeu Antonio Ferreira Melo
Jan 3 at 4:31
If you are facing difficulties in generating pojo's, you can use hibernate reverse engineering which will auto generate the pojo's based on the database schema. So that you don't need to worry about schema errors.
– venkat
Jan 3 at 4:33