Commit e190fefe authored by Maxym Borodenko's avatar Maxym Borodenko
Browse files

EmptyModel implements Persistable

parent 4d80d88f
......@@ -31,7 +31,7 @@ import com.fasterxml.jackson.annotation.JsonView;
* The Class BasicModel.
*/
@MappedSuperclass
public class BasicModel extends EmptyModel implements Persistable<Long> {
public class BasicModel extends EmptyModel {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 2709998920148999956L;
......@@ -61,19 +61,6 @@ public class BasicModel extends EmptyModel implements Persistable<Long> {
this.id = id;
}
/**
* Is the entity persisted to the database? Test is based on value of
* {@link #id} field where negative integers or null mean entity is not yet
* persisted.
*
* @return true if the {@link #id} is a positive integer, false otherwise
*/
@JsonIgnore
@Transient
public final boolean isNew() {
return (id == null) || (id.longValue() < 0);
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
......
......@@ -18,16 +18,32 @@ package org.genesys.blocks.model;
import java.io.Serializable;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.genesys.blocks.util.JsonClassNameWriter;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import org.springframework.data.domain.Persistable;
@MappedSuperclass
@JsonAppend(props = { @JsonAppend.Prop(name = "_class", value = JsonClassNameWriter.class, type = String.class) })
public abstract class EmptyModel implements EntityId, Serializable {
public abstract class EmptyModel implements EntityId, Serializable, Persistable<Long> {
/** The Constant serialVersionUID. */
private static final long serialVersionUID = 5934941826741972456L;
/**
* Is the entity persisted to the database? Test is based on value of
* {@link #getId()} field where negative integers or null mean entity is not yet
* persisted.
*
* @return true if the {@link #getId()} is a positive integer, false otherwise
*/
@JsonIgnore
@Transient
public final boolean isNew() {
return getId() == null || getId() < 0;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment