Package com.impetus.kundera.metadata.validator

Examples of com.impetus.kundera.metadata.validator.InvalidEntityDefinitionException


    }

    @Test
    public void testInvalidEntityDefintionException()
    {
        InvalidEntityDefinitionException exception = new InvalidEntityDefinitionException("Error with string");
        Assert.assertNotNull(exception);
   
        exception = new InvalidEntityDefinitionException();
        Assert.assertNotNull(exception);
    }
View Full Code Here


                mapKeyClass = mapKeyClassAnn.value();
            }

            if (mapKeyClass == null)
            {
                throw new InvalidEntityDefinitionException(
                        "For a Map relationship field,"
                                + " it is mandatory to specify Map key class either using @MapKeyClass annotation or through generics");
            }

        }

        // Check for target class specified at annotation
        if (targetEntity == null && null != m2mAnnotation.targetEntity()
                && !m2mAnnotation.targetEntity().getSimpleName().equals("void"))
        {
            targetEntity = m2mAnnotation.targetEntity();
        }
        //check if target entity is null
        if (targetEntity == null)
        {
            throw new InvalidEntityDefinitionException("Could not determine target entity class for relationship."
                    + " It should either be specified using targetEntity attribute of @ManyToMany or through generics");
        }
        //check if joined by foreign key
        if (isJoinedByFK)
        {
            throw new InvalidEntityDefinitionException(
                    "@JoinColumn not allowed for ManyToMany relationship. Use @JoinTable instead");

        }
      //check if joined by foreign key and join column name is set
        if (isJoinedByMap)
        {

            MapKeyJoinColumn mapKeyJoinColumnAnn = relationField.getAnnotation(MapKeyJoinColumn.class);
            if (mapKeyJoinColumnAnn != null)
            {
                String mapKeyJoinColumnName = mapKeyJoinColumnAnn.name();
                if (StringUtils.isEmpty(mapKeyJoinColumnName))
                {
                    throw new InvalidEntityDefinitionException(
                            "It's mandatory to specify name attribute with @MapKeyJoinColumn annotation");
                }
            }

        }
        //check if not joined by table in many to many
        if (!isJoinedByTable && !isJoinedByMap
                && (m2mAnnotation.mappedBy() == null || m2mAnnotation.mappedBy().isEmpty()))
        {
            throw new InvalidEntityDefinitionException(
                    "It's manadatory to use @JoinTable with parent side of ManyToMany relationship.");
        }
        return true;
    }
View Full Code Here

        String tableNameOfColumn = getTableNameOfColumn();
        if (tableNameOfColumn != null && !tables.contains(tableNameOfColumn) && !primaryTableName.isEmpty()
                && !primaryTableName.equals(tableNameOfColumn))
        {
            throw new InvalidEntityDefinitionException("Inavalid table " + tableNameOfColumn + " for field " + field);
        }
    }
View Full Code Here

            {
                embeddedCollection = new HashSet<Object>();
            }
            else
            {
                throw new InvalidEntityDefinitionException("Field " + embeddedCollectionField.getName()
                        + " must be either instance of List or Set");
            }
        }
        return embeddedCollection;
    }
View Full Code Here

        // Means if id attribute not found neither on entity or mappedsuper
        // class.

        if (idAttribute == null)
        {
            throw new InvalidEntityDefinitionException(clazz.getName() + " must have an @Id field.");
        }
    }
View Full Code Here

                if (log.isErrorEnabled())
                {
                    log.error("It is mandatory to specify Schema alongwith Table name:" + metadata.getTableName()
                            + ". This entity won't be persisted");
                }
                throw new InvalidEntityDefinitionException("It is mandatory to specify Schema alongwith Table name:"
                        + metadata.getTableName() + ". This entity won't be persisted");
            }
        }

        return metadata;
View Full Code Here

TOP

Related Classes of com.impetus.kundera.metadata.validator.InvalidEntityDefinitionException

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.