auto date
This commit is contained in:
snoop 2017-06-26 21:01:19 +09:00
parent b90e4dbf49
commit ab91e2e648
3 changed files with 72 additions and 1 deletions

View File

@ -34,7 +34,7 @@ public class MetaInfraVendor {
} }
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;
} }

View File

@ -60,6 +60,7 @@ public class ProbeTask {
this.data = data; this.data = data;
} }
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false) @Column(name = "CREATE_DATE", nullable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", insertable = false, updatable = false)
public Date getCreateDate() { public Date getCreateDate() {
return createDate; return createDate;

View File

@ -0,0 +1,70 @@
package com.loafle.overflow.meta.dao;
import com.loafle.overflow.AppConfig;
import com.loafle.overflow.JdbcConfiguration;
import com.loafle.overflow.meta.model.MetaInfraType;
import com.loafle.overflow.meta.model.MetaInfraVendor;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;
/**
* Created by snoop on 17. 6. 26.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {AppConfig.class, JdbcConfiguration.class})
public class MetaInfraVendorDAOTest {
@Autowired
private MetaInfraVendorDAO metaInfraVendorDAO;
@Test
public void create() {
MetaInfraType typeApp = new MetaInfraType();
typeApp.setId(7);
MetaInfraVendor vendorMySQL = new MetaInfraVendor();
vendorMySQL.setMetaInfraType(typeApp);
vendorMySQL.setName("MySql");
MetaInfraVendor vendorPost = new MetaInfraVendor();
vendorPost.setMetaInfraType(typeApp);
vendorPost.setName("PostgreSQL");
MetaInfraVendor vendorWMI = new MetaInfraVendor();
vendorWMI.setMetaInfraType(typeApp);
vendorWMI.setName("WMI");
MetaInfraVendor vendorSNMPV2 = new MetaInfraVendor();
vendorSNMPV2.setMetaInfraType(typeApp);
vendorSNMPV2.setName("SNMP_V2");
List<MetaInfraVendor> vendors = new ArrayList<>();
vendors.add(vendorMySQL);
vendors.add(vendorPost);
vendors.add(vendorWMI);
vendors.add(vendorSNMPV2);
int startIdx = 39;
for(int indexI = 0 ; indexI < vendors.size(); ++indexI) {
MetaInfraVendor v = vendors.get(indexI);
v.setId(indexI + startIdx);
this.metaInfraVendorDAO.save(v);
}
}
}