org.davesag.generica.core
Interface Persistable

All Known Implementing Classes:
AbstractCreditCardAuthoriser, AbstractDateStamped, CreditCard, Merchant, ShoppingItem, ShoppingOrder, User

public interface Persistable

All Persistable objects in our system use Long IDs as unique identifiers.

Since:
Generica 1.0
Version:
CVS Revision $Id: Persistable.java,v 1.6 2004/03/30 10:12:57 norm Exp $
Author:
Dave Sag http://www.davesag.com

Method Summary
 Long getId()
          Gets the Id number for this item.
 void setTemplateId(Long id)
          All Peristable items have an id, and by and large all of them shortcut the equals method and the hashcode methods to only compare on their given ids.
 

Method Detail

getId

public Long getId()
Gets the Id number for this item.

Returns:
The Id usually given to the object by a persistance manager such as Hibernate.

setTemplateId

public void setTemplateId(Long id)
All Peristable items have an id, and by and large all of them shortcut the equals method and the hashcode methods to only compare on their given ids. As a result you can do some handy template matches using collection.contains(item) rather than having to write you own more complex handlers. Simply sets the Id number for this item. This does not make it a persistable item however and you should be careful not to confuse it for an object that does. It is usually used as follows:
    User template = new User();
    template.setTemplateId(rowid);

    if (mUsers.contains(template)) {
            // do some stuff.
    }
 

Parameters:
id - The Id usually given to the object by a persistance manager such as Hibernate, but in your case if you are calling this method, you are hunting for an object in a collection.


Dave Sag Generica API version 0.5.9 - (prerelease) Copyright 2003 - 2004 Dave Sag.