private void registerObject(final Object obj) { if (obj == null) { return; } if (HibernateUtils.isEntity(obj.getClass()) == false) { return; } if (this.ignoreFromSaving.contains(obj.getClass()) == true) { // Don't need this objects as "top level" objects in list. They're usually encapsulated. return; } List<Object> list = this.allObjects.get(obj.getClass()); if (list == null) { list = new ArrayList<Object>(); this.allObjects.put(obj.getClass(), list); } list.add(obj); }
private void save(final Class<?> type) { if (ignoreFromSaving.contains(type) == true || writtenObjectTypes.contains(type) == true) { // Already written. return; } writtenObjectTypes.add(type); // Persistente Klasse? if (HibernateUtils.isEntity(type) == false) { return; } if (log.isDebugEnabled() == true) { log.debug("Writing objects from type: " + type); } final List<Object> list = allObjects.get(type); if (list == null) { return; } for (final Object obj : list) { if (obj == null || writtenObjects.contains(obj) == true) { // Object null or already written. Skip this item. continue; } if (session.contains(obj) == true) { continue; } try { if (log.isDebugEnabled()) { log.debug("Try to write object " + obj); } Serializable id = onBeforeSave(session, obj); if (id == null) { id = save(obj); } onAfterSave(obj, id); if (log.isDebugEnabled() == true) { log.debug("wrote object " + obj + " under id " + id); } } catch (final HibernateException ex) { log.fatal("Failed to write " + obj + " ex=" + ex, ex); } catch (final NullPointerException ex) { log.fatal("Failed to write " + obj + " ex=" + ex, ex); } } }
/** Should be set at initialization of ProjectForge after initialization of hibernate. */ public static void setConfiguration(final Configuration configuration) { instance.configuration = configuration; }
/** * Gets the length of the given property. * * @param entityName Class name of the entity * @param propertyName Java bean property name. * @return length if exists, otherwise null. */ public static Integer getPropertyLength(final String entityName, final String propertyName) { return instance.internalGetPropertyMaxLength(entityName, propertyName); }
/** * Gets the length of the given property. * * @param entityName Class name of the entity * @param propertyName Java bean property name. * @return length if exists, otherwise null. */ public static Integer getPropertyLength(final Class<?> entity, final String propertyName) { return instance.internalGetPropertyMaxLength(entity.getName(), propertyName); }
public static String getDBTableName(final Class<?> entity) { return instance.internalGetDBTableName(entity); }
public static boolean isEntity(final Class<?> entity) { return instance.internalIsEntity(entity); }