net.java.ao
Interface Entity

All Superinterfaces:
RawEntity<Integer>

public interface Entity
extends RawEntity<Integer>

A specific extension of RawEntity providing the getID() method. This interface should be sufficient for most entity needs. Only in cases where custom primary keys are required should RawEntity be directly extended.

Entity is the superinterface for most entity interfaces. For example, the following code defines an entity which maps to the "company" table (depending on what TableNameConverter is in use) with fields "name", "publiclyTraded" and "id" (names depending on the FieldNameConverter in use):

public class Company extends Entity {
     public String getName();
     public void setName(String name);
     
     public boolean isPubliclyTraded();
     public void setPubliclyTraded(boolean publiclyTraded);
 }

Author:
Daniel Spiewak
See Also:
RawEntity

Method Summary
 int getID()
          Retrieves the value of the "id" field in the entity; that is, the primary key.
 
Methods inherited from interface net.java.ao.RawEntity
addPropertyChangeListener, getEntityManager, getEntityType, init, removePropertyChangeListener, save
 

Method Detail

getID

int getID()

Retrieves the value of the "id" field in the entity; that is, the primary key. As this is the primary key, no database query will correspond with this method invocation.

For the moment, primary key fields are immutable. However, this will change before the 1.0 release as there are numerous use-cases for changing the value of a row's primary key field.

Returns:
The value of the primary key for the row, the "id" field.


Copyright © 2007-2014. All Rights Reserved.