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 methods getId() and setId() 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 the in any context where these methods are important while no id is set (e.g. in HashMaps).

Author:
  Philip W. Sorst
See Also:
  Serialized Form

### Constructor Summary

Constructors
Constructor and Description
`AbstractEntity()` Constructs an entity without the primary key being set.
`AbstractEntity(K id)` Constructs a new entity with the specified primary key.

### 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, setId`

### Constructor Detail

#### AbstractEntity

    public AbstractEntity()

Constructs an entity without the primary key being set.

#### AbstractEntity

    public AbstractEntity(K id)

Constructs a new entity with the specified primary key.

Parameters:
  `id` - The primary key.

### 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`