org.ujoframework.orm
Class OrmHandler

java.lang.Object
  extended by org.ujoframework.orm.OrmHandler

public class OrmHandler
extends java.lang.Object

The basic class for an ORM support.

Author:
Pavel Ponec

Constructor Summary
OrmHandler()
          The constructor
OrmHandler(java.lang.Class<UJO>... databaseModels)
          The constructor with a database metamodel initialization.
OrmHandler(java.lang.Class<UJO> databaseModel)
          The constructor with a database metamodel initialization.
 
Method Summary
 void addColumnModel(MetaRelation2Many column)
          Map a property to the table
 void addProcedureModel(MetaProcedure metaProcedure)
          Map a property to the table
 void addTableModel(MetaTable metaTable)
          Map a property to the table
 void config(MetaParams params)
          Save the ORM parameters.
 void config(MetaRoot config)
          Save the ORM configuration include parameters (if the parameters are not null).
 boolean config(java.lang.String url)
          Load parameters from an external XML file.
 boolean config(java.net.URL url, boolean throwsException)
          Load parameters from an external XML file.
 Session createSession()
          Create new session
 MetaRelation2Many findColumnModel(UjoProperty pathProperty)
          Find a Relation/Column model of the paramemeter property.
 MetaProcedure findProcedureModel(java.lang.Class<? extends DbProcedure> procedureClass)
          Find a procedure model by the procedureClass.
 java.util.List<UjoProperty> findPropertiesByType(java.lang.Class type)
          Find all persistent properties with the required type or subtype.
 MetaTable findTableModel(java.lang.Class<? extends OrmUjo> dbClass)
          Find a table model by the dbClass.
 java.lang.String getConfig()
          Returns a final meta-model in the XML format
 java.util.List<MetaDatabase> getDatabases()
          Returns all database
static OrmHandler getInstance()
          A candidate to removing
 MetaParams getParameters()
          Returns parameters
 Session getSession()
          Get a default Session of the OrmHandler.
 boolean isDatabaseLoaded()
          Returns true, if a database meta-model is loaded.
 boolean isPersistent(UjoProperty property)
          Is the parameter a persistent property?
 boolean isReadOnly()
          Do the handler have a read-only state?
<UJO extends OrmUjo>
void
loadDatabase(java.lang.Class<UJO>... databaseModel)
          Load a meta-data and create database tables
<UJO extends OrmUjo>
void
loadDatabase(java.lang.Class<UJO> databaseModel)
          Load a meta-data and create database tables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OrmHandler

public OrmHandler()
The constructor


OrmHandler

public OrmHandler(java.lang.Class<UJO> databaseModel)
The constructor with a database metamodel initialization.


OrmHandler

public OrmHandler(java.lang.Class<UJO>... databaseModels)
The constructor with a database metamodel initialization.

Method Detail

getInstance

public static OrmHandler getInstance()
A candidate to removing


getSession

public Session getSession()
Get a default Session of the OrmHandler. On a multi-thread application use a method createSession() rather.

See Also:
createSession()

createSession

public Session createSession()
Create new session


config

public boolean config(java.lang.String url)
               throws java.lang.IllegalArgumentException
Load parameters from an external XML file. The initialization must be finished before an ORM definition loading.

Throws:
java.lang.IllegalArgumentException

config

public void config(MetaParams params)
            throws java.lang.IllegalArgumentException
Save the ORM parameters. The assigning must be finished before an ORM definition loading.

Throws:
java.lang.IllegalArgumentException

config

public void config(MetaRoot config)
            throws java.lang.IllegalArgumentException
Save the ORM configuration include parameters (if the parameters are not null). The assigning must be finished before an ORM definition loading.

Throws:
java.lang.IllegalArgumentException

config

public boolean config(java.net.URL url,
                      boolean throwsException)
               throws java.lang.IllegalArgumentException
Load parameters from an external XML file. The initialization must be finished before an ORM definition loading.

Throws:
java.lang.IllegalArgumentException

isPersistent

public boolean isPersistent(UjoProperty property)
Is the parameter a persistent property?


loadDatabase

public final <UJO extends OrmUjo> void loadDatabase(java.lang.Class<UJO> databaseModel)
Load a meta-data and create database tables


loadDatabase

public <UJO extends OrmUjo> void loadDatabase(java.lang.Class<UJO>... databaseModel)
Load a meta-data and create database tables


isReadOnly

public boolean isReadOnly()
Do the handler have a read-only state?


addProcedureModel

public void addProcedureModel(MetaProcedure metaProcedure)
Map a property to the table


addTableModel

public void addTableModel(MetaTable metaTable)
Map a property to the table


addColumnModel

public void addColumnModel(MetaRelation2Many column)
Map a property to the table


findColumnModel

public MetaRelation2Many findColumnModel(UjoProperty pathProperty)
Find a Relation/Column model of the paramemeter property.

Parameters:
pathProperty - Parameter can be type of Property of PathProperty (direct or indirect);
Returns:
Returns a related model or the NULL if no model was found.

findTableModel

public MetaTable findTableModel(java.lang.Class<? extends OrmUjo> dbClass)
                         throws java.lang.IllegalStateException
Find a table model by the dbClass. If the table model is not found then the IllegalStateException is throwed.

Throws:
java.lang.IllegalStateException

findProcedureModel

public MetaProcedure findProcedureModel(java.lang.Class<? extends DbProcedure> procedureClass)
                                 throws java.lang.IllegalStateException
Find a procedure model by the procedureClass. If the procedure model is not found then the IllegalStateException is throwed.

Throws:
java.lang.IllegalStateException

getParameters

public MetaParams getParameters()
Returns parameters


isDatabaseLoaded

public boolean isDatabaseLoaded()
Returns true, if a database meta-model is loaded.


getDatabases

public java.util.List<MetaDatabase> getDatabases()
Returns all database


findPropertiesByType

public java.util.List<UjoProperty> findPropertiesByType(java.lang.Class type)
Find all persistent properties with the required type or subtype.

Parameters:
type - The parameter value Object.clas returns all persistent properties.

getConfig

public java.lang.String getConfig()
Returns a final meta-model in the XML format



Copyright © 2010. All Rights Reserved.