Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ElementCollection not getting saved #227

Closed
jeremyhahn opened this Issue · 3 comments

4 participants

@jeremyhahn

@Entity
@Table(name = "canned_task", schema = "myproject@default")
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="_class")
public class CannedTask implements Document {

@Id
@Column(name = "_id")
private String id;

@Column
private String task;

@Column
private String[] properties;

@Column
private String converter;

@ElementCollection
private Collection<ParameterMapping> mappings;

@Column
private String response;

@Column
private boolean executed;

@Column
private int taskTimeout;

public CannedTask() {
    mappings = new ArrayList<ParameterMapping>();
}

@Override
@JsonIgnore
public void setId(UniqueId id) {
    this.id = id.toString();
}

public void setId(String id) {
    this.id = id;
}

public String getId() {
    return id;
}

public void setTask(String task) {
    this.task = task;
}

public String getTask() {
    return task;
}

public void setProperties(String[] properties) {
    this.properties = properties;
}

public String[] getProperties() {
    return properties;
}

public String getConverter() {
    return converter;
}

public void setConverter(String converter) {
    this.converter = converter;
}

public Collection<ParameterMapping> getMappings() {
    return mappings;
}

public void setMappings(Collection<ParameterMapping> mappings) {
    this.mappings = mappings;
}

public void addMapping(ParameterMapping mapping) {
    mappings.add(mapping);
}

public boolean hasMappings() {
    return mappings.size() > 0;
}

public void setResponse(String response) {
    this.response = response;
}

public boolean hasResponse() {
    return response != null;
}

public String getResponse() {
    return response;
}

public boolean hasExecuted() {
    return executed;
}

@Override
public String toString() {
    return "Task [id=" + id + ", task=" + task + ", properties="
            + Arrays.toString(properties) + ", converter=" + converter
            + ", mappings=" + mappings + ", response=" + response
            + ", executed=" + executed + ", taskTimeout=" + taskTimeout + "]";
}

}

@Embeddable
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="_class")
public class ParameterMapping {

@Column
private String key;

@Column
private int references;

@Column
private String value;

public ParameterMapping() {
}

public ParameterMapping(String key, int references, String value) {
    super();
    this.key = key;
    this.references = references;
    this.value = value;
}

public String getKey() {
    return key;
}

public void setKey(String key) {
    this.key = key;
}

public int getReferences() {
    return references;
}

public void setReferences(int references) {
    this.references = references;
}

public String getValue() {
    return value;
}

public void setValue(String value) {
    this.value = value;
}

@Override
public String toString() {
    return "ParameterMapping [key=" + key + ", references=" + references 
            + ", value=" + value + "]";
}

}

Attempting to persist entity: Task [id=1039063b-3f17-4dd6-960f-52ec3180d4ee, task=my.package.project.workflow.CannedTask, properties=[null, 0, Workflow Folder 1], converter=null, mappings=[ParameterMapping [key=projectId, references=1, value=id]], response=null, executed=false, taskTimeout=10]

Entity stored in Mongo:
{ "_id" : "1039063b-3f17-4dd6-960f-52ec3180d4ee", "properties" : [ null, "0", "Workflow Folder 1" ], "executed" : false, "task" : "my.package.project.workflow.CannedTask", "mappings" : [ ], "taskTimeout" : 10 }

@xamry

We are working on this issue

@kkmishra

Can you please try changing following field definition:
private Collection mappings;

...with:
private List mappings;

...and test again.
Also, remove below attribute, since this is not a valid column declaration as per JPA specification, and hence is not supported in Kundera:
private String[] properties

@mevivs
Collaborator

Are we good to close on this?

@mevivs mevivs closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.