locked
Retrieve json data from table storage using java RRS feed

  • Question

  • Hi,

    We have a table in storage account that contain exactly 4 fields :- employeeId(PrimaryKey), employeeName(Rowkey), Timestamp and projectDetails (stored as Json data).

    We have the following EmployeeEntity Class

    import com.microsoft.azure.storage.table.TableServiceEntity;
    public class EmployeeEntity extends TableServiceEntity
    {

        private String employeeId;
        private String employeeName;
        private ProjectDetails projectDetails;

        public EmployeeEntity() {}
    public EmployeeEntity(String employeeId, String employeeName) 
    {
    this.partitionKey = employeeId;
    this.rowKey = employeeName;
    }


    public ProjectDetails getprojectDetails() 
    {
    return projectDetails;
    }


    public void setprojectDetails(ProjectDetails projectDetails) 
    {
    this.projectDetails = projectDetails;
    }
    }

    The ProjectDetails class is as follows

     

    public class ProjectDetails {

    private String projectId;
        private String projectName;
    private String description;

        public ProjectDetails() {}

    public ProjectDetails(String projectId, String projectName, String description) {
    this.projectId = projectId;
    this.projectName = projectName;
    this.description = description;
    }

    public String getProjectId() {
    return projectId;
    }

    public void setProjectId(String projectId) {
    this.projectId = projectId;
    }

    public String getProjectName() {
    return projectName;
    }

    public void setProjectName(String projectName) {
    this.projectName = projectName;
    }

    public String getdescription() {
    return description;
    }

    public void setdescription(String description) {
    this.description = description;
    }
    }

     Below is our table in azure

    PartitionKey

    RowKey

    Timestamp

    ProjectDetails

    Emp001

    Ram

    10/12/2015 10.52.12

    {"projectId":"pjt001","projectName":"JavaPJT","Description":java based project}

    We wrote code to retrieve data from this table as follows(given a portion of code)

    String partitionFilter = TableQuery.generateFilterCondition(PARTITION_KEY, QueryComparisons.EQUAL, "emp001");
    TableQuery<EmployeeEntity> partitionQuery = TableQuery.from(EmployeeEntity.class).where(partitionFilter);

    // Loop through the results, displaying information about the entity.

    for (EmployeeEntity entity : cloudTable.execute(partitionQuery)) {
    System.out.println(entity.getPartitionKey() + " " + entity.getRowKey() + "\t" + entity.getProjectDetails());
    }

    While running the above code, we are getting the following error
    java.util.NoSuchElementException: An error occurred while enumerating the result, check the original exception for details.
    at com.microsoft.azure.storage.core.LazySegmentedIterator.hasNext(LazySegmentedIterator.java:113)
    at com.table.sample.SampleRetrieval.main(SampleRetrieval.java:55)
    Caused by: com.microsoft.azure.storage.StorageException: The response received is invalid or improperly formatted.



    Tuesday, November 7, 2017 4:50 AM

All replies

  • For a deeper analysis of this issue, I would suggest you open a support ticket as described in this link How to create an Azure support request. The ticket will help you work closely with the support for speedy resolution.

    ------------------------------------------------------------------------------------------

    Do click on "Mark as Answer" on the post that helps you, this can be beneficial to other community members.

    Tuesday, November 7, 2017 12:05 PM