Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Allow creationDate and lastChanged to be set explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Jul 15, 2013
1 parent 452292d commit 08e23c3
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions zanata-model/src/main/java/org/zanata/model/ModelEntityBase.java
Expand Up @@ -102,18 +102,24 @@ public void setLastChanged(Date lastChanged)
@PrePersist
private void onPersist()
{
creationDate = new Date();
lastChanged = creationDate;
if (creationDate != null)
{
creationDate = new Date();
}
if (lastChanged != null)
{
lastChanged = creationDate;
}
}

@SuppressWarnings("unused")
@PreRemove
private void onRemove()
@PostPersist
private void postPersist()
{
if (logPersistence())
{
Logger log = LoggerFactory.getLogger(getClass());
log.info("remove entity: {}", this);
log.info("persist entity: {}", this);
}
}

Expand All @@ -125,13 +131,13 @@ private void onUpdate()
}

@SuppressWarnings("unused")
@PostPersist
private void postPersist()
@PreRemove
private void onRemove()
{
if (logPersistence())
{
Logger log = LoggerFactory.getLogger(getClass());
log.info("persist entity: {}", this);
log.info("remove entity: {}", this);
}
}

Expand Down

0 comments on commit 08e23c3

Please sign in to comment.