Updating entities with composite primary key in a datagrid

Hi,

I have an entity with composite primary key as shown below.

@DesignSupport("{'imported':true}")
@Table(name = "Books")
@Entity(name = "test_Books")
public class Books extends BaseGenericIdEntity<BooksCompKey> {
    private static final long serialVersionUID = -3697932020375183350L;
    @EmbeddedId
    protected BooksCompKey id;   
    @Column(name = "Category", length = 50)
    protected String category;
    @Override
    public void setId(BooksCompKey id) {
        this.id = id;
    }
    @Override
    public BooksCompKey getId() {
        return id;
    }
    public String getCategory() {
        return category;
    }

    public void setCategory(String category){
        this.category = category;
    }
}
@DesignSupport("{'imported':true}")
@MetaClass(name = "test_BooksCompKey")
@Embeddable
public class BooksCompKey extends EmbeddableEntity {
    private static final long serialVersionUID = -9160494969168442626L;
    @Column(name = "BookName", nullable = false, length = 128)
    protected String bookName;
    @Column(name = "AuthorId", nullable = false)
    protected Integer authorID;

    @Override
    public int hashCode() {
        return Objects.hash(authorID, bookName);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BooksCompKey entity = (BooksCompKey) o;
        return Objects.equals(this.authorID, entity.authorID) &&
                Objects.equals(this.bookName, entity.bookName);
    }

    public Integer getAuthorID() {
        return authorID;
    }

    public void setAuthorID(Integer authorID) {
        this.authorID = authorID;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }
}

I want to display this entity in a datagrid and edit the values in the grid.

<collection id="booksDc" class="com.test.entity.Books" view="_local">
            <loader id="booksDl"/>
</collection>
 <dataGrid id="booksGrid" dataContainer="booksDc" editorEnabled="true">                        
	<columns>
                        <column id="category" property="category" caption="Category"/>
                        <column id="id.bookName" property="id.bookName" caption="BookName"/>
                        <column id="id.authorID" property="id.authorID" caption="AuthorID"/>
  	</columns>
</dataGrid>

When i edit the values in the grid , I get the below exception
IllegalArgumentException: Can’t find getter for property ‘id.bookName’ at class com.test.entity.Books.

Could you please help to fix this issue?

Hi,
Thank you for reporting the problem. We have created the issue: https://github.com/cuba-platform/cuba/issues/2648
The exception occurs in crossFieldValidation logic. Probably, you can turn it off in DataGrid settings.
image

Regards.