diff --git a/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPort.java b/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPort.java index 02e9a53..79d6ba3 100644 --- a/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPort.java +++ b/src/main/java/com/loafle/bridge/discoveryport/DiscoveryPort.java @@ -32,7 +32,7 @@ public class DiscoveryPort { @Column(nullable = false) private int portNumber; - @OneToMany(mappedBy = "port") + @OneToMany(mappedBy = "port",cascade = CascadeType.ALL) private List histories; @OneToMany(mappedBy = "port" ,cascade = CascadeType.ALL) diff --git a/src/main/resources/database.properties b/src/main/resources/database.properties index 8703c98..d9f650f 100644 --- a/src/main/resources/database.properties +++ b/src/main/resources/database.properties @@ -10,6 +10,7 @@ spring.datasource.driver-class-name=org.h2.Driver ## Hibernate configuration spring.jpa.database=h2 -spring.jpa.hibernate.ddl-auto=create-drop +#spring.jpa.hibernate.ddl-auto=create-drop +spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.show-sql=true \ No newline at end of file diff --git a/src/test/java/com/loafle/bridge/discoveryport/repository/DiscoveryPortRepositoryTest.java b/src/test/java/com/loafle/bridge/discoveryport/repository/DiscoveryPortRepositoryTest.java index 2c683af..41877c6 100644 --- a/src/test/java/com/loafle/bridge/discoveryport/repository/DiscoveryPortRepositoryTest.java +++ b/src/test/java/com/loafle/bridge/discoveryport/repository/DiscoveryPortRepositoryTest.java @@ -7,7 +7,6 @@ import com.loafle.bridge.discoveryport.ServiceScanHistory; import com.loafle.bridge.discoveryport.type.DirectionType; import com.loafle.bridge.discoveryport.type.PortType; import org.apache.log4j.Logger; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,6 +38,7 @@ public class DiscoveryPortRepositoryTest { @Before + @Transactional public void Before() { repo.save(new DiscoveryPort(PortType.TCP,(short)1)); repo.save(new DiscoveryPort(PortType.UDP, (short)2)); @@ -47,14 +47,21 @@ public class DiscoveryPortRepositoryTest { repo.save(new DiscoveryPort(PortType.TCP, (short)5)); } - @After - public void After() { - repo.deleteAll(); - } +// @After +// public void After() { +// repo.deleteAll(); +// } @Test @Transactional public void TestInsertPort() { + + repo.save(new DiscoveryPort(PortType.TCP,(short)1)); + repo.save(new DiscoveryPort(PortType.UDP, (short)2)); + repo.save(new DiscoveryPort(PortType.TCP, (short)3)); + repo.save(new DiscoveryPort(PortType.UDP, (short)4)); + repo.save(new DiscoveryPort(PortType.TCP, (short)5)); + DiscoveryPort p = new DiscoveryPort(PortType.TCP, (short)1); repo.save(p);