Example follows:
private final static void openDB()
{
try
{
if( getOjbDBAlias() == null || getOjbDBAlias().length() == 0 )
{
throw new PersistenceBrokerException( "OJB Alias Value Cannot be null! Please set it properly before proceeding." );
}
LOGGER.log( Level.INFO, "Opening PersistenceBroker Database Instance." );
setBrokerKey( new PBKey( getOjbDBAlias() ) );
setBroker( PersistenceBrokerFactory.createPersistenceBroker( getBrokerKey() ) );
LOGGER.log( Level.FINE, "PersistenceBroker Data Access Layer ready!" );
}
catch( PBFactoryException e )
{
LOGGER.log( Level.SEVERE, "A PBFactoryException was thrown: " + e.getMessage() + "\n\n" );
}
catch( PersistenceBrokerException e )
{
LOGGER.log( Level.SEVERE, "An PersistenceBrokerException Occured while opening the database connection: " + e.getMessage() );
}
}
Easy enough, now once the app is started, there is only one method in the class file which can be used from my DAO layer and that is getBroker().
My question is:
Am I doing this as expected, or am I going to get in trouble for using the same broker instance for all DAO calls?
The way I would use this persistence broker is, for example:
broker.beginTransaction();
final Query query = QueryFactory.newQuery( Acronym.class, crit );
results = ( List ) broker.getCollectionByQuery( query );
broker.commitTransaction();I don't close the broker of course. Am I going to hit some locking issues here, or is one broker enough to handle getting connections from DB and handle multiple simultaneous calls?
Thanks R
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
