Limitations in google engine app?

Can Constraints be used in a Google engine application? Doesn't seem to work ... http://www.datanucleus.org/products/accessplatform_1_1/jpa/orm/constr ...

Property coding and code must be unique. Is there a workaround?

@Entity
@Table(uniqueConstraints = { 
    @UniqueConstraint(columnNames = { "codingSystem", "code" }) })
public class ArticleCode {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Key id;

    private String codingSystem;

    private String code;

      

Thanks Ralph

+2


source to share


2 answers


In a nutshell, no, it is not. The underlying datastore implementation does not support global transactions, so arbitrary unique constraints are impractical.



A workaround is to make unique components part of the key name.

+2


source


Thanks, works a lot.

Here is my new code.



@Entity public class ArticleCode {

@Id
private Key id;

@Column(name="codingSystem")
private String codingSystem;

@Column(name="code")
private String code;

public ArticleCode(Key parent, String codingSystem, String code) {
    this.id = KeyFactory.createKey(parent, ArticleCode.class.getSimpleName(), codingSystem + code);
    this.codingSystem = codingSystem;
    this.code = code;
}

      

+2


source







All Articles