-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REST API does not support entities with composite primary key #49
- Loading branch information
subbotin
committed
Feb 19, 2021
1 parent
e8a9dba
commit 486dc5f
Showing
12 changed files
with
277 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...estapi-demo/modules/global/src/com/haulmont/rest/demo/core/entity/CompositeKeyEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2008-2016 Haulmont. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.haulmont.rest.demo.core.entity; | ||
|
||
import com.haulmont.cuba.core.entity.BaseGenericIdEntity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.EmbeddedId; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
@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; | ||
|
||
@Column(name = "EMAIL") | ||
private String email; | ||
|
||
@Override | ||
public void setId(EntityKey id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public EntityKey getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getEmail() { | ||
return email; | ||
} | ||
|
||
public void setEmail(String email) { | ||
this.email = email; | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
test/restapi-demo/modules/global/src/com/haulmont/rest/demo/core/entity/EntityKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2008-2016 Haulmont. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.haulmont.rest.demo.core.entity; | ||
|
||
import com.haulmont.chile.core.annotations.MetaClass; | ||
import com.haulmont.cuba.core.entity.EmbeddableEntity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import java.util.Objects; | ||
|
||
@Embeddable | ||
@MetaClass(name = "ref$EntityKey") | ||
public class EntityKey extends EmbeddableEntity { | ||
|
||
@Column(name = "TENANT") | ||
private Integer tenant; | ||
|
||
@Column(name = "ENTITY_ID") | ||
private Long entityId; | ||
|
||
public Integer getTenant() { | ||
return tenant; | ||
} | ||
|
||
public void setTenant(Integer tenant) { | ||
this.tenant = tenant; | ||
} | ||
|
||
public Long getEntityId() { | ||
return entityId; | ||
} | ||
|
||
public void setEntityId(Long entityId) { | ||
this.entityId = entityId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof EntityKey)) return false; | ||
EntityKey entityKey = (EntityKey) o; | ||
return Objects.equals(tenant, entityKey.tenant) && | ||
Objects.equals(entityId, entityKey.entityId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(tenant, entityId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...odules/portal/test/com/haulmont/rest/demo/http/rest/data/updateEntityWithCompositeId.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name" : "modified name", | ||
"email": "modified email" | ||
} |