Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API does not support entities with composite primary key #49

Closed
haulmont-git opened this issue Jul 27, 2017 · 0 comments
Closed

REST API does not support entities with composite primary key #49

haulmont-git opened this issue Jul 27, 2017 · 0 comments
Assignees
Labels
state: fixed Fixed by the developer type: enhancement New feature or request ver: 7.2.3 Fixed in version ver: 7.3.0 Fixed in version
Milestone

Comments

@haulmont-git
Copy link

haulmont-git commented Jul 27, 2017

Since id of such entities is passed as object it's not possible to call some methods where id is used in path fragment

DELETE /entities/{entityName}/{entityId}
GET /entities/{entityName}/{entityId}
PUT /entities/{entityName}/{entityId}

Solution:
Represent composite key identifier as JSON string and apply base64 URL encoding.

Model:

@Entity(name = "ref$CompositeKeyEntity")
@Table(name = "REF_COMPOSITE_KEY")
public class CompositeKeyEntity extends BaseGenericIdEntity<EntityKey> {

    private static final long serialVersionUID = -2538345720324624741L;

    @EmbeddedId
    private EntityKey id;

    @Column(name = "NAME")
    private String name;  
}

@Embeddable
@MetaClass(name = "ref$EntityKey")
public class EntityKey extends EmbeddableEntity {

    @Column(name = "TENANT")
    private Integer tenant;

    @Column(name = "ENTITY_ID")
    private Long entityId;
}

Encoding sample:

  • JSON: {tenant : 1, entityId: 1}
  • Base 64: e3RlbmFudCA6IDEsIGVudGl0eUlkOiAxfQ==
  • GET /entities/ref$CompositeKeyEntity/e3RlbmFudCA6IDEsIGVudGl0eUlkOiAxfQ==

Original issue: https://youtrack.haulmont.com/issue/PL-9444

@gorbunkov gorbunkov transferred this issue from cuba-platform/cuba Aug 6, 2019
@gorbunkov gorbunkov removed their assignment Aug 7, 2019
@knstvk knstvk added this to the Release 7.2 milestone Feb 8, 2021
@knstvk knstvk added the type: enhancement New feature or request label Feb 8, 2021
@web-devel web-devel assigned andreysubbotin and unassigned t2-cuba Feb 8, 2021
andreysubbotin pushed a commit that referenced this issue Feb 19, 2021
@natfirst natfirst assigned skatova and unassigned natfirst Feb 20, 2021
@andreysubbotin andreysubbotin added ver: 7.2.3 Fixed in version ver: 7.3.0 Fixed in version labels Mar 4, 2021
@skatova skatova added the state: fixed Fixed by the developer label Mar 4, 2021
@skatova skatova closed this as completed Mar 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: fixed Fixed by the developer type: enhancement New feature or request ver: 7.2.3 Fixed in version ver: 7.3.0 Fixed in version
Projects
None yet
Development

No branches or pull requests

7 participants