Package org.cruxframework.crux.core.rebind

Examples of org.cruxframework.crux.core.rebind.CruxGeneratorException


        srcWriter.print(",\\\""+col+"\\\" "+getSQLTypeForProperty(propertyType)+" PRIMARY KEY");
        if (autoIncrement)
        {
          if (!getKeyTypeName().equals("Integer"))
          {
            throw new CruxGeneratorException("Auto increment keys can only be used on integer keys");
          }
          srcWriter.print(" AUTOINCREMENT");
        }
      }
      else
      {
        throw new CruxGeneratorException("Invalid KeyPath for object store ["+objectStoreName+"]. Duplicated column on keyPath ["+col+"]");
      }
    }

    StringBuilder uniqueConstraints = new StringBuilder();
    for (IndexData indexData: indexes)
View Full Code Here


        {
      JClassType objectStoreTarget = getObjectStoreTarget(objectStoreMetadata);
      String objectStoreName = getObjectStoreName(objectStoreMetadata, objectStoreTarget);
      if (addedObjectStores.contains(objectStoreName))
      {
        throw new CruxGeneratorException("Duplicated objectstore declared on Datasource ["+databaseMetadata.name()+"]");
      }
      addedObjectStores.add(objectStoreName);
     
      srcWriter.println(objectStoreVar +" = getObjectStore("+EscapeUtils.quote(objectStoreName)+", null);");
     
View Full Code Here

        {
      JClassType objectStoreTarget = getObjectStoreTarget(objectStoreMetadata);
      String objectStoreName = getObjectStoreName(objectStoreMetadata, objectStoreTarget);
      if (added.contains(objectStoreName))
      {
        throw new CruxGeneratorException("Duplicated ObjectStore found on Database["+databaseMetadata.name()+"]. ObjectStore["+objectStoreName+"]");
      }
      added.add(objectStoreName);
        }
    srcWriter.println("}");
  }
View Full Code Here

          List<IndexData> indexes = getIndexFromAnnotations(objectStoreTarget, "");
          for (IndexData index: indexes)
          {
            if (indexesCreated.contains(index.keyPath[0]))
            {
              throw new CruxGeneratorException("Duplicated index declared on ObjectSore ["+objectStoreName+"] Index ["+index.keyPath[0]+"] Datasource ["+databaseMetadata.name()+"]");
            }
            indexesCreated.add(index);
          }
        }
    }
View Full Code Here

    for (IndexDef index : indexMetadata)
    {
      String indexName = getIndexName(index, objectStoreName);
      if (indexesCreated.contains(indexName))
      {
        throw new CruxGeneratorException("Duplicated index declared on ObjectSore ["+objectStoreName+"] Index ["+indexName+"] Datasource ["+databaseMetadata.name()+"]");
      }
      if (index.keyPath() == null || index.keyPath().length == 0)
      {
        throw new CruxGeneratorException("Can not create an index without a key definition. Index ["+indexName+"] ObjectStore["+objectStoreName+"] Datasource ["+databaseMetadata.name()+"].");
      }
      indexesCreated.add(new IndexData(index.keyPath(), index.unique(), false, indexName)); // && index.multiEntry()
    }
  }
View Full Code Here

            if (indexed != null)
            {
              String property = JClassUtils.getPropertyForGetterOrSetterMethod(method);
              if (!isValidTypeForKey(method.getReturnType()))
              {
                throw new CruxGeneratorException("Invalid index type for index on method ["+method.getReadableDeclaration()+"]. Crux databases only support Strings, integers, double or dates as part of a key or index");
              }
              result.add(new IndexData(new String[]{prefix+property}, indexed.unique(), false, prefix+property));
            }
          }
          else
View Full Code Here

          str.append(key);
        }
   
    if (str.length() == 0)
    {
      throw new CruxGeneratorException("Invalid index declared on ObjectSore ["+objectStoreName+"] Datasource ["+databaseMetadata.name()+"]");
    }
   
    return str.toString();
   
  }
View Full Code Here

          Key key = method.getAnnotation(Key.class);
      if (key != null)
          {
        if (result && !key.autoIncrement())
        {
          throw new CruxGeneratorException("Invalid composite key declaration on objectStore ["+targetObject.getQualifiedSourceName()+"]. Can not use autoIncrement only on subset on keyPath set.");
        }
        if (key.autoIncrement() && !method.getReturnType().getQualifiedSourceName().equals("int") &&
          !method.getReturnType().getQualifiedSourceName().equals(Integer.class.getCanonicalName()))
        {
          throw new CruxGeneratorException("Invalid key declaration on objectStore ["+targetObject.getQualifiedSourceName()+"]. Can not use autoIncrement on a non int key.");
        }
            result = key.autoIncrement();
          }
        }
    return result;
View Full Code Here

          Key key = method.getAnnotation(Key.class);
      if (key != null)
          {
            if (!isValidTypeForKey(method.getReturnType()))
            {
              throw new CruxGeneratorException("Invalid key type for key on method ["+method.getReadableDeclaration()+"]. Crux databases only support Strings, integers, double or dates as part of a key or index");
            }
            keys.add(key);
            keyPath.add(JClassUtils.getPropertyForGetterOrSetterMethod(method));
          }
        }
    for (int i=0; i< keys.size(); i++)
    {
      int orderI = keys.get(i).order();
      if (orderI < 0 && keys.size() > 1)
      {
            throw new CruxGeneratorException("Crux object stores with composite keys must declare a valid order for its key's components");
      }
      int pos = i;
      for (int j=i+1; j < keys.size(); j++)
      {
        int orderJ = keys.get(j).order();
View Full Code Here

            {
              name = objectStoreTarget.getAnnotation(Store.class).value();
            }
            catch (Exception e)
            {
              throw new CruxGeneratorException("Invalid Database Store. You must inform a name on @ObjectStoreDef, or point to a target Class annotated with @Store.");
            }
    }
    return name;
  }
View Full Code Here

TOP

Related Classes of org.cruxframework.crux.core.rebind.CruxGeneratorException

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.