doanduyhai / Achilles

An advanced Java Object Mapper/Query DSL generator for Cassandra
http://achilles.archinnov.info
Apache License 2.0
241 stars 92 forks source link

@DSE_Search annotation is not allowed if using Cassandra version DSE 5.1.2. Consider setting your Cassandra version to DSE_X_X #318

Closed wizquest-labs closed 6 years ago

wizquest-labs commented 7 years ago

After updating to 5.3.1 version, I've started to get this error. However if I set DSE version to DSE_5_0_3, the application starts.

@CompileTimeConfig(cassandraVersion = CassandraVersion.DSE_5_0_3, columnMappingStrategy = ColumnMappingStrategy.IMPLICIT,
        namingStrategy = NamingStrategy.SNAKE_CASE, insertStrategy = InsertStrategy.NOT_NULL_FIELDS,
        projectName = "DMR_CSF")
public interface AchillesConfig {

}
doanduyhai commented 7 years ago

Easy bug, I'll attempt a new release soon

wizquest-labs commented 7 years ago

cool

wizquest-labs commented 7 years ago

@doanduyhai just a follow-up question on search implementation.

I'm trying to add @DSE_Search() on Enumerated type.

Its breaking the class generation for achilles as below:
Error:(665, 128) java: incompatible types: java.lang.String cannot be converted to demo.project.enums.TestEnum

Also when added @DSE_Search() on @PartitionKey

It breaks, on multiple fronts as below: Error:(822, 82) java: method parentResourceName() is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E

Error:(556, 60) java: cannot find symbol symbol: class W_J location: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex .. .. .. ..

ResourceHierarchyMappingEntity is the entity name for cassandra

doanduyhai commented 7 years ago

@wizquest-labs Can you please provide:

1) The entity with the annotations causing the issues 2) The complete exception stack trace for each issue

wizquest-labs commented 7 years ago

@doanduyhai sure. PFB the entity


@Table(table = "resource_hierarchy")
public class ResourceHierarchyMappingEntity {

    /** The mapping id. */
    private UUID mappingId;

    /** The parent resource name. */
    @PartitionKey
    @DSE_Search(fullTextSearchEnabled = true)
    private String parentResourceName;

    /** The parent resource type. */
    @Enumerated
    private ResourceType parentResourceType;

    /** The parent resource id. */
    private String parentResourceId;

    /** The child resource name. */
    @ClusteringColumn
    @DSE_Search(fullTextSearchEnabled = true)
    private String childResourceName;

    /** The child resource type. */
    @Enumerated
    @DSE_Search
    private ResourceType childResourceType;

    /** The child resource id. */
    private String childResourceId;

    /** The is archived. */
    private Boolean isArchived;

    /** The last modified time. */
    private Date lastModifiedTime;

    /** The creation time. */
    private Date creationTime;

    /** The mapping counter. */
    private Long mappingCounter;

    /**
     * Instantiates a new resource hierarchy mapping entity.
     *
     * @param mappingId
     *            the mapping id
     * @param parentResourceName
     *            the parent resource name
     * @param parentResourceType
     *            the parent resource type
     * @param parentResourceId
     *            the parent resource id
     * @param childResourceName
     *            the child resource name
     * @param childResourceType
     *            the child resource type
     * @param childResourceId
     *            the child resource id
     * @param isArchived
     *            the is archived
     * @param lastModifiedTime
     *            the last modified time
     * @param creationTime
     *            the creation time
     * @param mappingCounter
     *            the mapping counter
     */
    public ResourceHierarchyMappingEntity(UUID mappingId, String parentResourceName, ResourceType parentResourceType,
            String parentResourceId, String childResourceName, ResourceType childResourceType, String childResourceId,
            Boolean isArchived, Date lastModifiedTime, Date creationTime, Long mappingCounter) {
        this.mappingId = mappingId;
        this.parentResourceName = parentResourceName;
        this.parentResourceType = parentResourceType;
        this.parentResourceId = parentResourceId;
        this.childResourceName = childResourceName;
        this.childResourceType = childResourceType;
        this.childResourceId = childResourceId;
        this.isArchived = isArchived;
        this.lastModifiedTime = lastModifiedTime;
        this.creationTime = creationTime;
        this.mappingCounter = mappingCounter;
    }

    /**
     * Instantiates a new resource hierarchy mapping entity.
     */
    public ResourceHierarchyMappingEntity() {
    }

    /**
     * Gets the mapping id.
     *
     * @return the mapping id
     */
    public UUID getMappingId() {
        return mappingId;
    }

    /**
     * Sets the mapping id.
     *
     * @param mappingId
     *            the new mapping id
     */
    public void setMappingId(UUID mappingId) {
        this.mappingId = mappingId;
    }

    /**
     * Gets the parent resource name.
     *
     * @return the parent resource name
     */
    public String getParentResourceName() {
        return parentResourceName;
    }

    /**
     * Sets the parent resource name.
     *
     * @param parentResourceName
     *            the new parent resource name
     */
    public void setParentResourceName(String parentResourceName) {
        this.parentResourceName = parentResourceName;
    }

    /**
     * Gets the parent resource type.
     *
     * @return the parent resource type
     */
    public ResourceType getParentResourceType() {
        return parentResourceType;
    }

    /**
     * Sets the parent resource type.
     *
     * @param parentResourceType
     *            the new parent resource type
     */
    public void setParentResourceType(ResourceType parentResourceType) {
        this.parentResourceType = parentResourceType;
    }

    /**
     * Gets the parent resource id.
     *
     * @return the parent resource id
     */
    public String getParentResourceId() {
        return parentResourceId;
    }

    /**
     * Sets the parent resource id.
     *
     * @param parentResourceId
     *            the new parent resource id
     */
    public void setParentResourceId(String parentResourceId) {
        this.parentResourceId = parentResourceId;
    }

    /**
     * Gets the child resource name.
     *
     * @return the child resource name
     */
    public String getChildResourceName() {
        return childResourceName;
    }

    /**
     * Sets the child resource name.
     *
     * @param childResourceName
     *            the new child resource name
     */
    public void setChildResourceName(String childResourceName) {
        this.childResourceName = childResourceName;
    }

    /**
     * Gets the child resource type.
     *
     * @return the child resource type
     */
    public ResourceType getChildResourceType() {
        return childResourceType;
    }

    /**
     * Sets the child resource type.
     *
     * @param childResourceType
     *            the new child resource type
     */
    public void setChildResourceType(ResourceType childResourceType) {
        this.childResourceType = childResourceType;
    }

    /**
     * Gets the child resource id.
     *
     * @return the child resource id
     */
    public String getChildResourceId() {
        return childResourceId;
    }

    /**
     * Sets the child resource id.
     *
     * @param childResourceId
     *            the new child resource id
     */
    public void setChildResourceId(String childResourceId) {
        this.childResourceId = childResourceId;
    }

    /**
     * Gets the is archived.
     *
     * @return the archived
     */
    public Boolean getIsArchived() {
        return isArchived;
    }

    /**
     * Sets the is archived.
     *
     * @param archived
     *            the new archived
     */
    public void setIsArchived(Boolean archived) {
        isArchived = archived;
    }

    /**
     * Gets the last modified time.
     *
     * @return the last modified time
     */
    public Date getLastModifiedTime() {
        return lastModifiedTime;
    }

    /**
     * Sets the last modified time.
     *
     * @param lastModifiedTime
     *            the new last modified time
     */
    public void setLastModifiedTime(Date lastModifiedTime) {
        this.lastModifiedTime = lastModifiedTime;
    }

    /**
     * Gets the creation time.
     *
     * @return the creation time
     */
    public Date getCreationTime() {
        return creationTime;
    }

    /**
     * Sets the creation time.
     *
     * @param creationTime
     *            the new creation time
     */
    public void setCreationTime(Date creationTime) {
        this.creationTime = creationTime;
    }

    /**
     * Gets the mapping counter.
     *
     * @return the mapping counter
     */
    public Long getMappingCounter() {
        return mappingCounter;
    }

    /**
     * Sets the mapping counter.
     *
     * @param mappingCounter
     *            the new mapping counter
     */
    public void setMappingCounter(Long mappingCounter) {
        this.mappingCounter = mappingCounter;
    }
}

Error Messages when @DSE_Search is on @PartitionKey:

project/build/generated/source/apt/main/target/generated-sources/annotations/info/archinnov/achilles/generated/dsl/ResourceHierarchyMappingEntity_SelectIndex.java Error:(822, 82) java: method parentResourceName() is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E Error:(556, 60) java: cannot find symbol symbol: class W_J location: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex Error:(562, 60) java: cannot find symbol symbol: class E_J location: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex Error:(538, 60) java: cannot find symbol symbol: class W_TM location: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex Error:(544, 60) java: cannot find symbol symbol: class E_TM location: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex Error:(973, 18) java: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E.ParentResourceName is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E Error:(1295, 85) java: method parentResourceName() is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_TM Error:(1446, 18) java: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_TM.ParentResourceName is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_TM Error:(1768, 84) java: method parentResourceName() is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_J Error:(1919, 18) java: class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_J.ParentResourceName is already defined in class info.archinnov.achilles.generated.dsl.ResourceHierarchyMappingEntity_SelectIndex.E_J

Error Messages when @DSE_Search is on @Enumerated:

project/build/generated/source/apt/main/target/generated-sources/annotations/info/archinnov/achilles/generated/dsl/ResourceHierarchyMappingEntity_SelectIndex.java Error:(665, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType Error:(874, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType Error:(998, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType Error:(1207, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType Error:(1331, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType Error:(1540, 128) java: incompatible types: java.lang.String cannot be converted to enums.ResourceType

doanduyhai commented 7 years ago

Ok so for the first issue (@DSE_Search on @PartitionKey) the explanation is that Achilles has already generated the method parentResourceName() for the SELECT DSL (accessing rows by partition key. Since you added an @DSE_Search on it, Achilles also generates the method parentResourceName() in an internal class for search by index, thus having method name clashing.

I will have to modify the method name a little bit to avoid that.

For the 2nd issue, I guess that @DSE_Search expects to have a native supported type but has found the type ResourceType. There is some code change to have @DSE_Search accept the target CQL type of @Enumerated which is a String

wizquest-labs commented 7 years ago

@doanduyhai can you help me with the way forward here, with both the issues....need to implement these annotations on mentioned fields.

I can use the native query option anyday..right? i.e. if I do a schema change in cassandra and fire a native search query from the driver...that should return valid results...right?

doanduyhai commented 7 years ago

@wizquest-labs Yes, native query works. It's the escape route in case of new features not yet supported or bugs not yet fixed

Can you please provide the complete stack trace for @DSE_Search is on @enumerated ?

doanduyhai commented 6 years ago

The original bug is fixed