コード例 #1
0
 /**
  * Registers all children with their old and new id.
  *
  * @param children
  * @param oldIdList The returned list of beforeSave(...) method.
  */
 protected void afterSave(
     final Collection<? extends BaseDO<? extends Serializable>> children,
     final List<Serializable> oldIdList) {
   if (oldIdList == null) {
     return;
   }
   final Iterator<Serializable> oldIdListIterator = oldIdList.iterator();
   final Iterator<? extends BaseDO<?>> childIterator = children.iterator();
   while (oldIdListIterator.hasNext() == true) {
     final BaseDO<?> child = childIterator.next();
     registerEntityMapping(child.getClass(), oldIdListIterator.next(), child.getId());
   }
 }
コード例 #2
0
 /**
  * @param obj
  * @return
  */
 public static <T extends Serializable> void setIdentifier(final BaseDO<T> obj, final T value) {
   if (Hibernate.isInitialized(obj) == true) {
     obj.setId(value);
   } else if (obj instanceof DefaultBaseDO) {
     ((DefaultBaseDO) obj).setId((Integer) value);
   } else if (obj instanceof AccessEntryDO) {
     ((AccessEntryDO) obj).setId((Integer) value);
   } else if (obj instanceof Kost2ArtDO) {
     ((Kost2ArtDO) obj).setId((Integer) value);
   } else if (obj instanceof KundeDO) {
     ((KundeDO) obj).setId((Integer) value);
   } else if (obj instanceof UserPrefEntryDO) {
     ((UserPrefEntryDO) obj).setId((Integer) value);
   } else {
     log.error(
         "Couldn't set the identifier of the given object for class: " + obj.getClass().getName());
   }
 }
コード例 #3
0
 /**
  * Workaround for: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3502:
  *
  * @param obj
  * @return
  */
 public static Serializable getIdentifier(final BaseDO<?> obj) {
   if (Hibernate.isInitialized(obj) == true) {
     return ((BaseDO<?>) obj).getId();
   } else if (obj instanceof DefaultBaseDO) {
     return ((DefaultBaseDO) obj).getId();
   } else if (obj instanceof AccessEntryDO) {
     return ((AccessEntryDO) obj).getId();
   } else if (obj instanceof Kost2ArtDO) {
     return ((Kost2ArtDO) obj).getId();
   } else if (obj instanceof KundeDO) {
     return ((KundeDO) obj).getId();
   } else if (obj instanceof UserPrefEntryDO) {
     return ((UserPrefEntryDO) obj).getId();
   }
   log.error(
       "Couldn't get the identifier of the given object (Jassist/Hibernate-Bug: HHH-3502) for class: "
           + obj.getClass().getName());
   return null;
 }