Package nexj.core.meta.persistence

Examples of nexj.core.meta.persistence.ClassMapping


            }

            if (!bNull)
            {
               // TODO: Insert with composition mappings.
               ClassMapping assocMapping = (ClassMapping)attributeMapping;
               boolean bSuccessor = isCreateSuccessor(primaryWork, assocMapping, bOID);

               if (bSuccessor)
               {
                  if (list == null)
                  {
                     inst.getAdapter().addDependency(uow, primaryWork, inst,
                        assocMapping.getKey(true), assocMapping.getKey(false), true);
                  }
                  else
                  {
                     for (int k = 0; k < list.getCount(); ++k)
                     {
                        inst = list.getInstance(k);

                        if (inst != null)
                        {
                           inst.getAdapter().addDependency(uow, primaryWork, inst,
                              assocMapping.getKey(true), assocMapping.getKey(false), true);
                        }
                     }
                  }
               }
               else
               {
                  Work work = addClassWork(uow, instance, primaryWork, assocMapping);

                  if (list != null)
                  {
                     inst = list.getInstance(0);
                  }

                  if (inst.getOID() != null)
                  {
                     work.setKeyValue(assocMapping.getKey(false), assocMapping.getKey(true), inst);

                     if (assocMapping.getKey(false) == mapping.getObjectKey())
                     {
                        instance.setOID(inst.getOID());
                     }
                  }
                  else
                  {
                     inst.getAdapter().addDependency(uow, work, inst,
                        assocMapping.getKey(false), assocMapping.getKey(true), false);
                  }
               }
            }
         }
View Full Code Here


            {
               inst = (Instance)value;
               bNull = (inst == null);
            }

            ClassMapping assocMapping = (ClassMapping)attributeMapping;
            boolean bSuccessor;

            // TODO: Update composition mappings

            if (assocMapping.getKey(false).isObjectKey())
            {
               bSuccessor = true;
            }
            else if (assocMapping.getKey(true).isObjectKey())
            {
               bSuccessor = false;
            }
            else if (attribute.isCollection())
            {
               bSuccessor = true;
            }
            else
            {
               bSuccessor = false;
            }

            if (bSuccessor)
            {
               if (!bNull)
               {
                  if (list == null)
                  {
                     inst.getAdapter().addDependency(uow, primaryWork, inst,
                        assocMapping.getKey(true), assocMapping.getKey(false), true);
                  }
                  else
                  {
                     for (int k = 0; k < list.getCount(); ++k)
                     {
                        inst = list.getInstance(k);

                        if (inst != null)
                        {
                           inst.getAdapter().addDependency(uow, primaryWork, inst,
                              assocMapping.getKey(true), assocMapping.getKey(false), true);
                        }
                     }
                  }
               }
            }
            else
            {
               Work work = addClassWork(uow, instance, primaryWork, assocMapping);

               if (bNull)
               {
                  if (assocMapping.getKey(false) != mapping.getObjectKey())
                  {
                     work.setKeyValue(assocMapping.getKey(false), assocMapping.getKey(true), null);
                  }
               }
               else
               {
                  if (list != null)
                  {
                     inst = list.getInstance(0);
                  }

                  if (inst.getOID() != null)
                  {
                     if (assocMapping.getKey(false) != mapping.getObjectKey())
                     {
                        work.setKeyValue(assocMapping.getKey(false), assocMapping.getKey(true), inst);
                     }
                  }
                  else
                  {
                     inst.getAdapter().addDependency(uow, work, inst,
                        assocMapping.getKey(false), assocMapping.getKey(true), false);
                  }
               }
            }
         }
View Full Code Here

                  if (!bRoot)
                  {
                     query.makeRoot(m_context);
                  }

                  ClassMapping mapping = (ClassMapping)query.getAttributeMapping();
                  boolean bHeterogeneous = !(mapping instanceof VirtualClassMapping) ||
                     !isComposition(query, (VirtualClassMapping)mapping);

                  if (bHeterogeneous)
                  {
                     if (!bRoot)
                     {
                        query.addRoot(query);
                     }

                     setParentItem(query, attribute, mapping);
                     setChildItem(query, attribute, mapping);
                     query.setOutput(!mapping.isInner());
                  }
                  else
                  {
                     query.setGenerator(new VirtualJoinTab());
                     query.setParentItem(createOIDItem(query));
                     query.setChildItem(null);
                     query.setOutput(true); // no additional RPC cost to querying composition mappings
                  }
               }

               return true;
            }

            private void setChildItem(Query query, Attribute attribute, ClassMapping mapping)
            {
               if (mapping.getKey(true).isObjectKey())
               {
                  // Parent has FK
                  query.setChildItem(createOIDItem(query));
               }
               else
               {
                  // Child has FK
                  query.setChildItem(createKeyItem((VirtualKey)mapping.getKey(true), query));
               }
            }

            private void setParentItem(Query query, Attribute attribute, ClassMapping mapping)
            {
               Key srcKey = mapping.getKey(false);

               if (srcKey.isObjectKey())
               {
                  // Child has FK
                  query.setParentItem(createOIDItem(query.getParent()));
View Full Code Here

TOP

Related Classes of nexj.core.meta.persistence.ClassMapping

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.