Package org.jboss.ejb.plugins.cmp.jdbc.metadata

Examples of org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCOptimisticLockingMetaData


      // CMR fields
      loadCMRFields(metadata);

      // create locking field
      JDBCOptimisticLockingMetaData lockMetaData = metadata.getOptimisticLocking();
      if(lockMetaData != null && lockMetaData.getLockingField() != null)
      {
         Integer strategy = lockMetaData.getLockingStrategy();
         JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField();

         versionField = getCMPFieldByName(versionMD.getFieldName());
         boolean hidden = versionField == null;
         if(strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY)
         {
            if(hidden)
               versionField = new JDBCLongVersionFieldBridge(manager, versionMD);
            else
               versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)versionField);
         }
         else if(strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY)
         {
            if(hidden)
               versionField = new JDBCTimestampVersionFieldBridge(manager, versionMD);
            else
               versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)versionField);
         }
         else if(strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY)
         {
            if(hidden)
               versionField = new JDBCKeyGenVersionFieldBridge(
                  manager, versionMD, lockMetaData.getKeyGeneratorFactory());
            else
               versionField = new JDBCKeyGenVersionFieldBridge(
                  (JDBCCMP2xFieldBridge)versionField, lockMetaData.getKeyGeneratorFactory());
         }

         if(hidden)
            addCMPField(versionField);
         else
View Full Code Here


      throws DeploymentException
   {
      loadGroupMasks = new HashMap();

      // load optimistic locking mask and add it to all the load group masks
      JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking();
      if(olMD != null)
      {
         if(versionField != null)
         {
            defaultLockGroupMask = new boolean[tableFields.length];
            defaultLockGroupMask[versionField.getTableIndex()] = true;
            versionField.setLockingStrategy(LockingStrategy.VERSION);
         }
         else if(olMD.getGroupName() != null)
         {
            defaultLockGroupMask = loadGroupMask(olMD.getGroupName(), null);
            for(int i = 0; i < tableFields.length; ++i)
            {
               if(defaultLockGroupMask[i])
               {
                  JDBCCMPFieldBridge tableField = tableFields[i];
                  tableField.setLockingStrategy(LockingStrategy.GROUP);
                  tableField.addDefaultFlag(ADD_TO_WHERE_ON_UPDATE);
               }
            }
         }
         else // read or modified strategy
         {
            LockingStrategy strategy =
               (olMD.getLockingStrategy() == JDBCOptimisticLockingMetaData.READ_STRATEGY ?
               LockingStrategy.READ : LockingStrategy.MODIFIED
               );
            for(int i = 0; i < tableFields.length; ++i)
            {
               JDBCCMPFieldBridge field = tableFields[i];
View Full Code Here

   public void init() throws DeploymentException
   {
      loadCMPFields(metadata);
      loadCMRFields(metadata);

      JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking();
      if(olMD != null)
      {
         if(olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY)
         {
            throw new DeploymentException(
               "Only version-column optimistic locking strategy is supported at the moment.");
         }

         JDBCCMPFieldMetaData versionMD = olMD.getLockingField();
         versionField = (JDBCCMPFieldBridge2) getFieldByName(versionMD.getFieldName());
      }
   }
View Full Code Here

/*     */     throws DeploymentException
/*     */   {
/*  90 */     loadCMPFields(this.metadata);
/*  91 */     loadCMRFields(this.metadata);
/*     */
/*  93 */     JDBCOptimisticLockingMetaData olMD = this.metadata.getOptimisticLocking();
/*  94 */     if (olMD != null)
/*     */     {
/*  96 */       if (olMD.getLockingStrategy() != JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY)
/*     */       {
/*  98 */         throw new DeploymentException("Only version-column optimistic locking strategy is supported at the moment.");
/*     */       }
/*     */
/* 102 */       JDBCCMPFieldMetaData versionMD = olMD.getLockingField();
/* 103 */       this.versionField = ((JDBCCMPFieldBridge2)getFieldByName(versionMD.getFieldName()));
/*     */     }
/*     */   }
View Full Code Here

/*      */
/*  162 */     loadCMPFields(this.metadata);
/*      */
/*  165 */     loadCMRFields(this.metadata);
/*      */
/*  168 */     JDBCOptimisticLockingMetaData lockMetaData = this.metadata.getOptimisticLocking();
/*  169 */     if ((lockMetaData != null) && (lockMetaData.getLockingField() != null))
/*      */     {
/*  171 */       Integer strategy = lockMetaData.getLockingStrategy();
/*  172 */       JDBCCMPFieldMetaData versionMD = lockMetaData.getLockingField();
/*      */
/*  174 */       this.versionField = getCMPFieldByName(versionMD.getFieldName());
/*  175 */       boolean hidden = this.versionField == null;
/*  176 */       if (strategy == JDBCOptimisticLockingMetaData.VERSION_COLUMN_STRATEGY)
/*      */       {
/*  178 */         if (hidden)
/*  179 */           this.versionField = new JDBCLongVersionFieldBridge(this.manager, versionMD);
/*      */         else
/*  181 */           this.versionField = new JDBCLongVersionFieldBridge((JDBCCMP2xFieldBridge)this.versionField);
/*      */       }
/*  183 */       else if (strategy == JDBCOptimisticLockingMetaData.TIMESTAMP_COLUMN_STRATEGY)
/*      */       {
/*  185 */         if (hidden)
/*  186 */           this.versionField = new JDBCTimestampVersionFieldBridge(this.manager, versionMD);
/*      */         else
/*  188 */           this.versionField = new JDBCTimestampVersionFieldBridge((JDBCCMP2xFieldBridge)this.versionField);
/*      */       }
/*  190 */       else if (strategy == JDBCOptimisticLockingMetaData.KEYGENERATOR_COLUMN_STRATEGY)
/*      */       {
/*  192 */         if (hidden) {
/*  193 */           this.versionField = new JDBCKeyGenVersionFieldBridge(this.manager, versionMD, lockMetaData.getKeyGeneratorFactory());
/*      */         }
/*      */         else {
/*  196 */           this.versionField = new JDBCKeyGenVersionFieldBridge((JDBCCMP2xFieldBridge)this.versionField, lockMetaData.getKeyGeneratorFactory());
/*      */         }
/*      */       }
/*      */
/*  200 */       if (hidden)
/*  201 */         addCMPField(this.versionField);
View Full Code Here

/*      */   private void loadLoadGroups(JDBCEntityMetaData metadata)
/*      */     throws DeploymentException
/*      */   {
/* 1015 */     this.loadGroupMasks = new HashMap();
/*      */
/* 1018 */     JDBCOptimisticLockingMetaData olMD = metadata.getOptimisticLocking();
/* 1019 */     if (olMD != null)
/*      */     {
/* 1021 */       if (this.versionField != null)
/*      */       {
/* 1023 */         this.defaultLockGroupMask = new boolean[this.tableFields.length];
/* 1024 */         this.defaultLockGroupMask[this.versionField.getTableIndex()] = true;
/* 1025 */         this.versionField.setLockingStrategy(LockingStrategy.VERSION);
/*      */       }
/* 1027 */       else if (olMD.getGroupName() != null)
/*      */       {
/* 1029 */         this.defaultLockGroupMask = loadGroupMask(olMD.getGroupName(), null);
/* 1030 */         for (int i = 0; i < this.tableFields.length; i++)
/*      */         {
/* 1032 */           if (this.defaultLockGroupMask[i] == 0)
/*      */             continue;
/* 1034 */           JDBCCMPFieldBridge tableField = this.tableFields[i];
/* 1035 */           tableField.setLockingStrategy(LockingStrategy.GROUP);
/* 1036 */           tableField.addDefaultFlag(64);
/*      */         }
/*      */
/*      */       }
/*      */       else
/*      */       {
/* 1042 */         LockingStrategy strategy = olMD.getLockingStrategy() == JDBCOptimisticLockingMetaData.READ_STRATEGY ? LockingStrategy.READ : LockingStrategy.MODIFIED;
/*      */
/* 1046 */         for (int i = 0; i < this.tableFields.length; i++)
/*      */         {
/* 1048 */           JDBCCMPFieldBridge field = this.tableFields[i];
/* 1049 */           if (!field.isPrimaryKeyMember()) {
View Full Code Here

TOP

Related Classes of org.jboss.ejb.plugins.cmp.jdbc.metadata.JDBCOptimisticLockingMetaData

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.