'Spring JPA resulting in error executing delete DDL?
Hello I'm new to Spring and I am trying to create a model which maps to a table in Apache Derby (using it for testing), the issue is I get a Error executing DDL "drop table potatoes" via JDBC Statement, I heard it is generally caused by using a SQL keyword however I don't think I'm using any:
Users.java:
@Entity
public class Users {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String username;
private String firstname;
private String lastname;
private String email;
private String passwordHash;
public Users(){}
public Users(String username, String firstname, String lastname, String email, String passwordHash) {
this.username = username;
this.firstname = firstname;
this.lastname = lastname;
this.email = email;
this.passwordHash = passwordHash;
}
...
Solution 1:[1]
Probably you are using HQL - Hibernate Query Language and something like
entityManager.createQuery("drop table potatoes;").executeUpdate();
DROP is an invalid statement in HQL. If you want to use DROP you have to use not HQL, but SQL and native query. Please try:
entityManager.createNativeQuery("drop table potatoes;").executeUpdate();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Vladimir.V.Bvn |
