This commit is contained in:
jackdaw 2016-11-16 18:38:01 +09:00
parent 2d719f18ba
commit ca0deca18c
3 changed files with 15 additions and 7 deletions

View File

@ -32,7 +32,7 @@ public class DiscoveryPort {
@Column(nullable = false) @Column(nullable = false)
private int portNumber; private int portNumber;
@OneToMany(mappedBy = "port") @OneToMany(mappedBy = "port",cascade = CascadeType.ALL)
private List<ServiceScanHistory> histories; private List<ServiceScanHistory> histories;
@OneToMany(mappedBy = "port" ,cascade = CascadeType.ALL) @OneToMany(mappedBy = "port" ,cascade = CascadeType.ALL)

View File

@ -10,6 +10,7 @@ spring.datasource.driver-class-name=org.h2.Driver
## Hibernate configuration ## Hibernate configuration
spring.jpa.database=h2 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.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.show-sql=true spring.jpa.show-sql=true

View File

@ -7,7 +7,6 @@ import com.loafle.bridge.discoveryport.ServiceScanHistory;
import com.loafle.bridge.discoveryport.type.DirectionType; import com.loafle.bridge.discoveryport.type.DirectionType;
import com.loafle.bridge.discoveryport.type.PortType; import com.loafle.bridge.discoveryport.type.PortType;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -39,6 +38,7 @@ public class DiscoveryPortRepositoryTest {
@Before @Before
@Transactional
public void Before() { public void Before() {
repo.save(new DiscoveryPort(PortType.TCP,(short)1)); repo.save(new DiscoveryPort(PortType.TCP,(short)1));
repo.save(new DiscoveryPort(PortType.UDP, (short)2)); repo.save(new DiscoveryPort(PortType.UDP, (short)2));
@ -47,14 +47,21 @@ public class DiscoveryPortRepositoryTest {
repo.save(new DiscoveryPort(PortType.TCP, (short)5)); repo.save(new DiscoveryPort(PortType.TCP, (short)5));
} }
@After // @After
public void After() { // public void After() {
repo.deleteAll(); // repo.deleteAll();
} // }
@Test @Test
@Transactional @Transactional
public void TestInsertPort() { 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); DiscoveryPort p = new DiscoveryPort(PortType.TCP, (short)1);
repo.save(p); repo.save(p);