From dec5f4252bee257030896b488ba46dfd8efa7f42 Mon Sep 17 00:00:00 2001 From: Nathan Cannon Date: Fri, 21 Sep 2018 11:11:49 +0100 Subject: [PATCH] Hibernate can now actually create tables. --- backend/configuration.yml | 1 + .../main/java/uk/co/neviyn/Observations/core/BaseEntity.java | 3 ++- .../src/main/java/uk/co/neviyn/Observations/dao/SiteDao.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/configuration.yml b/backend/configuration.yml index 5bed63d..88f044a 100644 --- a/backend/configuration.yml +++ b/backend/configuration.yml @@ -8,6 +8,7 @@ database: # any properties specific to your JDBC driver: properties: foreign_keys: true + hibernate.hbm2ddl.auto: create server: rootPath: /api/ \ No newline at end of file diff --git a/backend/src/main/java/uk/co/neviyn/Observations/core/BaseEntity.java b/backend/src/main/java/uk/co/neviyn/Observations/core/BaseEntity.java index 43ed287..cdf840b 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/core/BaseEntity.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/core/BaseEntity.java @@ -7,6 +7,7 @@ import lombok.NoArgsConstructor; import lombok.NonNull; import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.MappedSuperclass; import java.io.Serializable; @@ -19,6 +20,6 @@ class BaseEntity implements Serializable { @NonNull @JsonProperty @Id - @GeneratedValue + @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; } diff --git a/backend/src/main/java/uk/co/neviyn/Observations/dao/SiteDao.java b/backend/src/main/java/uk/co/neviyn/Observations/dao/SiteDao.java index b6675c9..ed375da 100644 --- a/backend/src/main/java/uk/co/neviyn/Observations/dao/SiteDao.java +++ b/backend/src/main/java/uk/co/neviyn/Observations/dao/SiteDao.java @@ -12,7 +12,7 @@ public class SiteDao extends AbstractDAO { } public List listAll(){ - return list(criteriaQuery()); + return currentSession().createQuery("from Site", Site.class).list(); } public Site get(long id){