org.mentabean
Class BaseMentaBean

java.lang.Object
  extended by org.mentabean.BaseMentaBean
All Implemented Interfaces:
MentaBean

public class BaseMentaBean
extends Object
implements MentaBean

A base implementation of MentaBean to be used by composition.

Author:
sergio.oliveira.jr@gmail.com

Constructor Summary
BaseMentaBean(Object bean, BeanSession session)
           
 
Method Summary
 boolean delete()
          Attempt to delete a bean from the database.
 void insert()
          Attempt to insert a bean to the database.
 boolean load()
          Attempt to load the bean properties from the database.
 boolean update()
          Attempt to update the bean properties in the database.
 boolean updateAll()
          Attempt to update ALL the bean properties in the database, not just the ones that have been changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseMentaBean

public BaseMentaBean(Object bean,
                     BeanSession session)
Method Detail

insert

public void insert()
Description copied from interface: MentaBean
Attempt to insert a bean to the database. Note: This method can be called multiple times in the same bean. Of course the PK constraints will be enforced by the database, so you can change the PK by hand and call this method multiple times, to insert multiple beans. If the PK is an auto-generated database field (e.g. auto-increment), you will not change the PK by hand and a new PK will be automatically assigned to the bean.

Specified by:
insert in interface MentaBean

load

public boolean load()
Description copied from interface: MentaBean
Attempt to load the bean properties from the database. This method will throw an exception if you try to load a bean without its primary key set.

Specified by:
load in interface MentaBean
Returns:
true if the bean was loaded

update

public boolean update()
Description copied from interface: MentaBean
Attempt to update the bean properties in the database. If this bean was previously loaded, this method will update only the properties that were modified (dirty).

Specified by:
update in interface MentaBean
Returns:
true if it was updated

updateAll

public boolean updateAll()
Description copied from interface: MentaBean
Attempt to update ALL the bean properties in the database, not just the ones that have been changed.

Specified by:
updateAll in interface MentaBean
Returns:
true if it was updated

delete

public boolean delete()
Description copied from interface: MentaBean
Attempt to delete a bean from the database. It will throw an exception if the bean does not have its PK set.

Specified by:
delete in interface MentaBean
Returns:
true if it was deleted


Copyright © 2011. All Rights Reserved.