org.mentabean
Interface MentaBean

All Known Implementing Classes:
AbstractMentaBean

public interface MentaBean

The functionality of a MentaBean, in other words, the methods you can call on a mentabean to perform database operations like insert, load, reload, save, update and delete.

Author:
Sergio Oliveira Jr.

Method Summary
 boolean delete()
          Attempt to delete a bean from the database.
 BeanSession getBeanSession()
          Return the bean session being used by this menta bean.
 void insert()
          Attempt to insert a bean to the database.
 boolean load()
          Attempt to load the bean properties from the database.
 int save(Object... forceNull)
          Attempt to save a bean in 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.
 

Method Detail

insert

void insert()
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.


load

boolean load()
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.

Returns:
true if the bean was loaded

update

boolean update()
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).

Returns:
true if it was updated

updateAll

boolean updateAll()
Attempt to update ALL the bean properties in the database, not just the ones that have been changed.

Returns:
true if it was updated

delete

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

Returns:
true if it was deleted

save

int save(Object... forceNull)
Attempt to save a bean in the database. It will try update first, then insert.

Returns:
0 when UPDATE and 1 if operation was an INSERT
See Also:
BeanSession.save(Object, Object...)

getBeanSession

BeanSession getBeanSession()
Return the bean session being used by this menta bean.

Returns:
the bean session


Copyright © 2013. All Rights Reserved.