JPA-Map storage might loose writes due to missing locking mechanism
Closes #9411
This commit is contained in:
parent
0c9ab32cf4
commit
61fbb2fb2e
2 changed files with 13 additions and 0 deletions
|
@ -36,6 +36,7 @@ import javax.persistence.FetchType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Version;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.annotations.TypeDef;
|
||||
import org.hibernate.annotations.TypeDefs;
|
||||
|
@ -54,6 +55,11 @@ public class JpaClientEntity extends AbstractClientEntity implements Serializabl
|
|||
@Column
|
||||
private UUID id;
|
||||
|
||||
//used for implicit optimistic locking
|
||||
@Version
|
||||
@Column
|
||||
private int version;
|
||||
|
||||
@Type(type = "jsonb")
|
||||
@Column(columnDefinition = "jsonb")
|
||||
private final JpaClientMetadata metadata;
|
||||
|
@ -131,6 +137,10 @@ public class JpaClientEntity extends AbstractClientEntity implements Serializabl
|
|||
metadata.setEntityVersion(entityVersion);
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return id == null ? null : id.toString();
|
||||
|
|
|
@ -29,6 +29,9 @@ limitations under the License.
|
|||
<column name="id" type="UUID">
|
||||
<constraints primaryKey="true" nullable="false"/>
|
||||
</column>
|
||||
<column name="version" type="INTEGER" defaultValueNumeric="0">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="metadata" type="json"/>
|
||||
</createTable>
|
||||
<ext:addGeneratedColumn tableName="client">
|
||||
|
|
Loading…
Reference in a new issue