I don't think it matters how many MapBuilders you have.  I guess when I
think of a DatabaseMap, I assume there is one DatabaseMap per database.  I
do not see the reason to have multiple DatabaseMaps per database, though
maybe there is a good reason.  Are people creating multiple TableMaps per
table with each one only containing some of the columns in the table?

It does not make sense to use the IDBroker for one DatabaseMap (default) to
generate keys for a table that is described in a TableMap located in a
different DatabaseMap (mytables).  If you have a DatabaseMap that contains
tables for which you are planning to use IDBroker to generate keys, you will
need to add the ID_TABLE to that DatabaseMap.  Hopefully this will not cause
a problem if you are adding the same table to different DatabaseMaps, but I
cannot be sure.

Beyond all that, it is probably alright to just synchronize on the IDBroker
itself.  I was trying to limit the synchronized block as much as possible,
but the main caller of the storeId method will be IDBroker's update thread
and it goes through the tables sequentially anyway.  Thoughts?

John McNally

----- Original Message -----
From: Leon Messerschmidt <[EMAIL PROTECTED]>
To: Turbine <[EMAIL PROTECTED]>
Sent: Thursday, July 13, 2000 7:47 AM
Subject: New IDBroker problem


> Hi,
>
> I tried to use the new IDBroker and I ran into some trouble.  I used
NewGenerateMapBuilderTask to generate Peers and MapBuilders for
> my application's tables and I used the built-in Turbine Peers and
MapBuilder (TurbineMapBuilder) to manage the security.  The
> id_table is also part of the Turbine tables.  I got a NullPointerException
when I tried to use IDBroker to generate an id for one of
> my tables in the following way:
>
> DatabaseMap dbMap = DBBroker.getInstance().getDatabaseMap("default");
> IDBroker idb = dbMap.getIDBroker();
> entityid = idb.getNextId ("Entity").intValue();
>
> The problem turned out to be that IDBroker tries to synchronize on the
table map for which your are trying to generate an id.
> Because I have my own MapBuilder for my tables the TurbineMapBuilder does
not have this table and throws the exception.  Am I using
> this in the wrong way - should I have *one* MapBuilder for the whole app?
Am I right if I say that I can't add the id_table to each
> of the MapBuilders because of synchronization problems?
>
> At the moment I use a very simple workaround in storeIDs() , although this
is not the most elegant code:
>
>     DatabaseMap dbMap = tableMap.getDatabaseMap();
>     Object tMap = dbMap.getTable(tableName);
>     if (tMap == null) tMap = this;
>     synchronized(tMap)
>
> Any other thoughts on this?
>
> ~ Leon
>
>
>
> ------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
> Problems?:           [EMAIL PROTECTED]
>



------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search: <http://www.mail-archive.com/turbine%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to