Sha256: 4c50358a17d94c57c866a141282afd6ee25a4c7bd5afab98d5a16f4dce0df187

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

package <%=@package%>.model;

<%=@licence%>

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.springframework.hateoas.Identifiable;

/**
 * Base entity for neo4j entities.
 *
 * @author <%=@user_name%>
 */
@NodeEntity
@JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public abstract class BaseEntity implements Identifiable<Long> {

  @GraphId
  private Long nodeId;

  private long id;

  public Long getNodeId() {
    return nodeId;
  }

  public void setNodeId(Long nodeId) {
    this.nodeId = nodeId;
  }

  public Long getId() {
    return id;
  }

  public void setId(long id) {
    this.id = id;
  }


  @Override
  public boolean equals(Object other) {
    if (this == other) {
      return true;
    }

    if (other == null || getClass() != other.getClass()) {
      return false;
    }

    BaseEntity entity = (BaseEntity) other;
    if (id == 0) {
      return super.equals(other);
    }
    return id == entity.getId();

  }

  @Override
  public int hashCode() {
    return (int)id;
  }

}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
spring-gen-0.2.3 lib/templates/src/main/java/model/neo4j/Neo4jBaseEntity.java.erb
spring-gen-0.2.2 lib/templates/src/main/java/model/neo4j/Neo4jBaseEntity.java.erb
spring-gen-0.2.1 lib/templates/resource/model/Neo4jBaseEntity.java.erb
spring-gen-0.2.0 lib/templates/resource/model/Neo4jBaseEntity.java.erb