CLOUDSTACK-8186: make setRemoved to null possible

This commit is contained in:
Wei Zhou 2017-04-14 22:41:17 +08:00 committed by Rohit Yadav
parent de0d1c7893
commit 03aca885ae
3 changed files with 4 additions and 3 deletions

View File

@ -771,7 +771,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO, Long> implem
tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date()); tmpltZoneVO = new VMTemplateZoneVO(zoneId, tmplt.getId(), new Date());
_templateZoneDao.persist(tmpltZoneVO); _templateZoneDao.persist(tmpltZoneVO);
} else { } else {
tmpltZoneVO.setRemoved(null); tmpltZoneVO.setRemoved(GenericDaoBase.DATE_TO_NULL);
tmpltZoneVO.setLastUpdated(new Date()); tmpltZoneVO.setLastUpdated(new Date());
_templateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO); _templateZoneDao.update(tmpltZoneVO.getId(), tmpltZoneVO);
} }

View File

@ -11,7 +11,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>cloud-framework-db</artifactId> <artifactId>cloud-framework-db</artifactId>
<name>Apache CloudStack Framework - Event Notification</name> <name>Apache CloudStack Framework - Database</name>
<parent> <parent>
<groupId>org.apache.cloudstack</groupId> <groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-framework</artifactId> <artifactId>cloudstack-framework</artifactId>

View File

@ -158,6 +158,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
protected static final String FOR_UPDATE_CLAUSE = " FOR UPDATE "; protected static final String FOR_UPDATE_CLAUSE = " FOR UPDATE ";
protected static final String SHARE_MODE_CLAUSE = " LOCK IN SHARE MODE"; protected static final String SHARE_MODE_CLAUSE = " LOCK IN SHARE MODE";
protected static final String SELECT_LAST_INSERT_ID_SQL = "SELECT LAST_INSERT_ID()"; protected static final String SELECT_LAST_INSERT_ID_SQL = "SELECT LAST_INSERT_ID()";
public static final Date DATE_TO_NULL = new Date(Long.MIN_VALUE);
protected static final SequenceFetcher s_seqFetcher = SequenceFetcher.getInstance(); protected static final SequenceFetcher s_seqFetcher = SequenceFetcher.getInstance();
@ -1537,7 +1538,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> extends Compone
} }
} else if (attr.field.getType() == Date.class) { } else if (attr.field.getType() == Date.class) {
final Date date = (Date)value; final Date date = (Date)value;
if (date == null) { if (date == null || date.equals(DATE_TO_NULL)) {
pstmt.setObject(j, null); pstmt.setObject(j, null);
return; return;
} }