org.ujoframework.implementation.orm
Class OrmTable<UJO_IMPL extends Ujo>

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.implementation.quick.QuickUjo
          extended by org.ujoframework.implementation.orm.OrmTable<UJO_IMPL>
All Implemented Interfaces:
java.io.Serializable, UjoCloneable, UjoTextable, ExtendedOrmUjo<UJO_IMPL>, OrmUjo, Ujo

public class OrmTable<UJO_IMPL extends Ujo>
extends QuickUjo
implements ExtendedOrmUjo<UJO_IMPL>

This abstract implementation of the OrmUjo interface is situable for implementation the persistent entities.
Instances of the OrmTable are serializable, but you need to know that only business data will be transferred, the session and property changes will not be passed.
The sample of use:

  /** Using INSERT */
  public void useCreateItem() {

      Order order = new Order();
      order.set(Order.DATE, new Date());
      order.set(Order.DESCR, "John's order");

      Item item = new Item();
      item.set(Item.ORDER, order);
      item.set(Item.DESCR, "Yellow table");

      Session session = OrmHandler.getInstance().getSession();
      session.save(order);
      session.save(item);
      session.commit();
  }

Author:
Pavel Ponec
See Also:
RelationToMany, UjoIterator, Serialized Form

Constructor Summary
OrmTable()
           
 
Method Summary
<UJO extends UJO_IMPL,VALUE>
VALUE
get(UjoProperty<UJO,VALUE> property)
          Getter based on UjoProperty implemeted by a pattern UjoExt
protected static
<UJO extends OrmTable,ITEM extends OrmTable>
RelationToMany<UJO,ITEM>
newRelation(java.lang.Class<ITEM> type)
          A PropertyIterator Factory creates an new property and assign a next index.
protected static
<UJO extends OrmTable,ITEM extends OrmTable>
RelationToMany<UJO,ITEM>
newRelation(java.lang.String name, java.lang.Class<ITEM> type)
          A PropertyIterator Factory creates an new property and assign a next index.
 boolean readAuthorization(UjoAction action, UjoProperty property, java.lang.Object value)
          Test an authorization of the action.
<UJO extends UJO_IMPL>
ForeignKey
readFK(UjoProperty<UJO,? extends OrmUjo> property)
          Read the foreign key.
 UjoProperty[] readChangedProperties(boolean clear)
          Returns a changed properties.
 Session readSession()
          Read a session
 java.lang.Object readValue(UjoProperty property)
          A method for an internal use only.
<UJO extends UJO_IMPL,VALUE>
UJO_IMPL
set(UjoProperty<UJO,VALUE> property, VALUE value)
          Setter based on UjoProperty.
 void writeSession(Session session)
          Write a session
 void writeValue(UjoProperty property, java.lang.Object value)
          A method for an internal use only.
 
Methods inherited from class org.ujoframework.implementation.quick.QuickUjo
newListProperty, newListProperty, newProperty, newProperty, newProperty, newProperty, newProperty, newProperty
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
clone, equals, init, init, readProperties, readUjoManager, readValueString, toString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujoframework.Ujo
readProperties
 

Constructor Detail

OrmTable

public OrmTable()
Method Detail

readSession

public Session readSession()
Read a session

Specified by:
readSession in interface OrmUjo

writeSession

public void writeSession(Session session)
Write a session

Specified by:
writeSession in interface OrmUjo

writeValue

public void writeValue(UjoProperty property,
                       java.lang.Object value)
A method for an internal use only.

Specified by:
writeValue in interface Ujo
Overrides:
writeValue in class QuickUjo
Parameters:
property - Property must be a direct type only!
See Also:
Property.setValue(Ujo,Object)

readValue

public java.lang.Object readValue(UjoProperty property)
A method for an internal use only.

Specified by:
readValue in interface OrmUjo
Specified by:
readValue in interface Ujo
Overrides:
readValue in class QuickUjo
Parameters:
property - Property must be a direct type only!
Returns:
Property value
See Also:
Property.getValue(Ujo)

readChangedProperties

public UjoProperty[] readChangedProperties(boolean clear)
Returns a changed properties. The method is not the thread save.

Specified by:
readChangedProperties in interface OrmUjo
Parameters:
clear - True value clears the property changes.

get

public final <UJO extends UJO_IMPL,VALUE> VALUE get(UjoProperty<UJO,VALUE> property)
Getter based on UjoProperty implemeted by a pattern UjoExt


set

public final <UJO extends UJO_IMPL,VALUE> UJO_IMPL set(UjoProperty<UJO,VALUE> property,
                                                       VALUE value)
Setter based on UjoProperty. Type of value is checked in the runtime. The method was implemented by a pattern UjoExt.


readAuthorization

public boolean readAuthorization(UjoAction action,
                                 UjoProperty property,
                                 java.lang.Object value)
Test an authorization of the action.

Specified by:
readAuthorization in interface Ujo
Overrides:
readAuthorization in class AbstractUjo
Parameters:
action - Type of request. See constant(s) ACTION_* for more information. The action must not be null, however there is allowed to use a dummy constant UjoAction.DUMMY .
property - A property of the Ujo
value - A value
Returns:
Returns TRUE, if property is authorized.
See Also:
Action Constants

readFK

public <UJO extends UJO_IMPL> ForeignKey readFK(UjoProperty<UJO,? extends OrmUjo> property)
                  throws java.lang.IllegalStateException
Read the foreign key. This is useful to obtain the foreign key value without (lazy) loading the entire object. If the lazy object is loaded, the method will need the Session to build the ForeignKey instance.
NOTE: The method is designed for developers only, the Ujorm doesn't call it newer.

Specified by:
readFK in interface ExtendedOrmUjo<UJO_IMPL extends Ujo>
Returns:
If no related object is available, then the result has the NULL value.
Throws:
java.lang.IllegalStateException - Method throws an exception for a wrong property type.
java.lang.NullPointerException - Method throws an exception if a Session is missing after a lazy initialization of the property.

newRelation

protected static <UJO extends OrmTable,ITEM extends OrmTable> RelationToMany<UJO,ITEM> newRelation(java.lang.String name,
                                                                                                   java.lang.Class<ITEM> type)
A PropertyIterator Factory creates an new property and assign a next index.


newRelation

protected static <UJO extends OrmTable,ITEM extends OrmTable> RelationToMany<UJO,ITEM> newRelation(java.lang.Class<ITEM> type)
A PropertyIterator Factory creates an new property and assign a next index.



Copyright © 2010. All Rights Reserved.