Package nexj.core.meta.persistence.sql

Examples of nexj.core.meta.persistence.sql.Index


         else if (component != null)
         {
            oid = ((OIDGenerator)component.getInstance(uow.getInvocationContext())).generateOID(instance, this);

            Object[] values = oid.getValueArray();
            Index pk = primaryTable.getPrimaryKey();
            int nCount = pk.getIndexColumnCount();

            if (nCount != values.length)
            {
               throw new PersistenceException("err.persistence.oidValueCount",
                  new Object[]{component.getName(), Primitive.createInteger(nCount),
                     Primitive.createInteger(values.length)});
            }

            for (int i = 0; i < nCount; ++i)
            {
               values[i] = pk.getIndexColumn(i).getColumn().getValueType().convert(values[i]);
            }

            instance.setOID(oid);
            primaryWork.setOID();
         }
         else
         {
            Metaclass metaclass = instance.getMetaclass();

            for (int i = 0, n = 0, nCount = metaclass.getInstanceAttributeCount(); i < nCount; ++i)
            {
               Attribute attribute = metaclass.getInstanceAttribute(i);
               AttributeMapping mapping = relMapping.getAttributeMapping(attribute);
               int nPrimaryColCount = primaryTable.getPrimaryKey().getIndexColumnCount();

               if (mapping instanceof RelationalPrimitiveMapping)
               {
                  Column column = ((RelationalPrimitiveMapping)mapping).getColumn();

                  if (column.isPrimary())
                  {
                     primaryWork.setValue(column, column.getValueType().convert(instance.getValue(i)));

                     if (++n >= nPrimaryColCount)
                     {
                        break;
                     }
                  }
               }
               else if (mapping instanceof RelationalClassMapping)
               {
                  Index index = ((RelationalClassMapping)mapping).getSourceKey();

                  if (index.isObjectKeyPart())
                  {
                     Object value = instance.getValue(i);

                     if (value instanceof OIDHolder)
                     {
                        oid = ((OIDHolder)value).getOID();

                        if (oid != null )
                        {
                           int nIndexColCount = index.getIndexColumnCount();

                           if (nIndexColCount == oid.getCount())
                           {
                              for (int k = 0; k < nIndexColCount; ++k)
                              {
                                 Column column = index.getIndexColumn(k).getColumn();

                                 if (column.isPrimary())
                                 {
                                    primaryWork.setValue(column, column.getValueType().convert(oid.getValue(k)));
View Full Code Here


         {
            Query assoc = source.getQuery();

            if (assoc.getParent() == query)
            {
               Index index = (Index)query.getKey(false);

               for (int i = 0, n = index.getIndexColumnCount(); i < n; ++i)
               {
                  columnSet.add(index.getIndexColumn(i).getColumn());
               }
            }
         }
      }

      if (!columnSet.isEmpty())
      {
         Set tableSet = new HashHolder(columnSet.size() >> 2);

         for (Iterator itr = columnSet.iterator(); itr.hasNext();)
         {
            tableSet.add(((Column)itr.next()).getTable());
         }

         for (Iterator itr = tableSet.iterator(); itr.hasNext();)
         {
            Table table = (Table)itr.next();

         loop:
            for (int nIndex = 0, nIndexCount = table.getIndexCount(); nIndex < nIndexCount; ++nIndex)
            {
               Index index = table.getIndex(nIndex);

               if (index.isUnique() &&
                  (index.getType() == Index.BTREE || index.getType() == Index.CLUSTER))
               {
                  for (int i = 0, n = index.getIndexColumnCount(); i < n; ++i)
                  {
                     if (!columnSet.contains(index.getIndexColumn(i).getColumn()))
                     {
                        continue loop;
                     }
                  }
View Full Code Here

         {
            Table table = mapping.getTable(nTable);

            for (int nIndex = 0, nIndexCount = table.getIndexCount(); nIndex < nIndexCount; ++nIndex)
            {
               Index index = table.getIndex(nIndex);

               if (indexNameMatches(index, sIndexName))
               {
                  if (index.isUnique() && index.getIndexColumnCount() != 0)
                  {
                     Pair keys = mapping.getUniqueKeys(index);

                     if (keys != null)
                     {
View Full Code Here

TOP

Related Classes of nexj.core.meta.persistence.sql.Index

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.