net.dontdrinkandroot.persistence.entity

## Class AbstractEntity<K>

- java.lang.Object
- - net.dontdrinkandroot.persistence.entity.AbstractEntity<K>

Type Parameters:
  `K` - Type of the primary key.

All Implemented Interfaces:
  Serializable, Entity<K>

Direct Known Subclasses:
  AbstractGeneratedIdEntity, AbstractIdEntity, GeneratedLongIdEntity, LongIdEntity

    @MappedSuperclass
    public abstract class AbstractEntity<K>
    extends Object
    implements Entity<K>

Represents an entity with a primary key. The method getId() must be implemented, even if the primary key has a different field name, also make sure that the primary key implements equals/hashcode correctly. hashCode() and equals() are based on the id, so make sure not to use id in any context where these methods are important while no id is set (e.g. in HashMaps) or you must override them.

Author:
  Philip W. Sorst
See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`AbstractEntity()` Constructs an entity without the primary key being set.

### Method Summary

Methods
`boolean` `equals(Object obj)`
`int` `hashCode()`
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface net.dontdrinkandroot.persistence.entity.Entity

`getId`

### Constructor Detail

#### AbstractEntity

    public AbstractEntity()

Constructs an entity without the primary key being set.

### Method Detail

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### equals

    public boolean equals(Object obj)

Overrides:
  `equals` in class `Object`