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.Id;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.persistence.Version;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
import org.hibernate.annotations.TypeDef;
|
import org.hibernate.annotations.TypeDef;
|
||||||
import org.hibernate.annotations.TypeDefs;
|
import org.hibernate.annotations.TypeDefs;
|
||||||
|
@ -54,6 +55,11 @@ public class JpaClientEntity extends AbstractClientEntity implements Serializabl
|
||||||
@Column
|
@Column
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
//used for implicit optimistic locking
|
||||||
|
@Version
|
||||||
|
@Column
|
||||||
|
private int version;
|
||||||
|
|
||||||
@Type(type = "jsonb")
|
@Type(type = "jsonb")
|
||||||
@Column(columnDefinition = "jsonb")
|
@Column(columnDefinition = "jsonb")
|
||||||
private final JpaClientMetadata metadata;
|
private final JpaClientMetadata metadata;
|
||||||
|
@ -131,6 +137,10 @@ public class JpaClientEntity extends AbstractClientEntity implements Serializabl
|
||||||
metadata.setEntityVersion(entityVersion);
|
metadata.setEntityVersion(entityVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id == null ? null : id.toString();
|
return id == null ? null : id.toString();
|
||||||
|
|
|
@ -29,6 +29,9 @@ limitations under the License.
|
||||||
<column name="id" type="UUID">
|
<column name="id" type="UUID">
|
||||||
<constraints primaryKey="true" nullable="false"/>
|
<constraints primaryKey="true" nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
|
<column name="version" type="INTEGER" defaultValueNumeric="0">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
<column name="metadata" type="json"/>
|
<column name="metadata" type="json"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
<ext:addGeneratedColumn tableName="client">
|
<ext:addGeneratedColumn tableName="client">
|
||||||
|
|
Loading…
Reference in a new issue