| 18 | private final HashMap<Class<?>, TableEntity<?>> tableMap = new HashMap<Class<?>, TableEntity<?>>(); |
| 19 | |
| 20 | @Override |
| 21 | @SuppressWarnings("unchecked") |
| 22 | public <T> TableEntity<T> getTable(Class<T> entityType) throws DbException { |
| 23 | synchronized (tableMap) { |
| 24 | TableEntity<T> table = (TableEntity<T>) tableMap.get(entityType); |
| 25 | if (table == null) { |
| 26 | try { |
| 27 | table = new TableEntity<T>(this, entityType); |
| 28 | } catch (DbException ex) { |
| 29 | throw ex; |
| 30 | } catch (Throwable ex) { |
| 31 | throw new DbException(ex); |
| 32 | } |
| 33 | tableMap.put(entityType, table); |
| 34 | } |
| 35 | |
| 36 | return table; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void dropTable(Class<?> entityType) throws DbException { |