crate / spring-data-crate

Apache License 2.0
3 stars 2 forks source link

Issue with bulkinsert and bulkupdate #26

Open akandach opened 8 years ago

akandach commented 8 years ago

i am using spring crate and calling bulkInsert but i am seeing the below error. org.springframework.data.crate.CrateSQLActionException: io.crate.shade.org.elasticsearch.transport.RemoteTransportException: [Boost][inet[/127.0.0.1:4300]][crate_bulk_sql] if u look at the query 'INSERT INTO connect_notifications ("datejoined","enterprisename","entity_class","fromprofileid","fromuserid","id","message","modificationtime","requestaccepted","requestsent","toemail","toprofileid","type") VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)' with args '[[com.clidentity.server.model.Notification, 07311936-09f6-4c75-b5c3-ae6ae222d800, d69a6e9f-e7f3-479f-afd3-2b093633ef7a, 3bea25a2-7d8f-431e-8ca3-5ccb9f87face, batta prasad, 2f681c0f-2efa-459b-b59a-fd8f02f7425a, CONNECT]]' input parameters seems to be wrong.

It very easy to reproduce the issue. Just create array of object to persist using bulk insert. May be same with bulk update.

If you look at the parameter value i am setting only few properties but it is taking all the parameters from the object and constructing it in the query and also the order is not correct. The object class is the first arg but where in the query it is third argument.

Hope this will help you in reproducing the issue. Please do let me know once it is fixed.

Also can you guys push the jar file to the repository so that we can include the dependency in the pom file.

joemoe commented 8 years ago

hi @akandach, thanks for reporting the issue. we'll have a look at it and provide you more information.

kovrus commented 8 years ago

Hi @akandach, I've tried to reproduce your issue related to bulk insert a complex type which contains an array, list and set of objects. I suppose that what you meant by "Just create array of object to persist using bulk insert". Despite the fact, that there are some tests for complex types, i have written a small integration test based on your explanation. You can take a look at it here. Here i am trying to bulk insert a list which contains a single complex object type with the set, list and array fields.

It would be also nice if you could provide us with some gist of how you've defined the types and how you use the repository to insert the data.

akandach commented 8 years ago

Here is what i am doing. Hope this helps @Transactional public BulkOperartionResult upsert(List notification) { try { return simpleNotificationRepository.bulkInsert(notification); }catch(Exception e) { e.printStackTrace(); } return null; }

package com.clidentity.server.model;

import org.springframework.data.annotation.PersistenceConstructor; import org.springframework.data.crate.core.mapping.annotations.Table;

@Table(name = "connect_notifications", refreshInterval = 500, numberOfReplicas = "0-all") public class Notification extends BaseEntity {

/**
 * 
 */
private static final long serialVersionUID = 1L;

private String fromuserid;

private String requestsent;

private String fromprofileid;

private String toprofileid;

private String requestaccepted;

private String toemail;

private ConnectionType type;

private String enterprisename;

private String message;

@PersistenceConstructor
public Notification() {
}

public ConnectionType getType() {
    return type;
}

public void setType(ConnectionType type) {
    this.type = type;
}

public String getMessage() {
    return message;
}

public void setMessage(String message) {
    this.message = message;
}

public String getFromprofileid() {
    return fromprofileid;
}

public void setFromprofileid(String fromprofileid) {
    this.fromprofileid = fromprofileid;
}

public String getToprofileid() {
    return toprofileid;
}

public void setToprofileid(String toprofileid) {
    this.toprofileid = toprofileid;
}

public String getEnterprisename() {
    return enterprisename;
}

public void setEnterprisename(String enterprisename) {
    this.enterprisename = enterprisename;
}

public String getToemail() {
    return toemail;
}

public void setToemail(String toemail) {
    this.toemail = toemail;
}

public String getFromuserid() {
    return fromuserid;
}

public void setFromuserid(String fromuserid) {
    this.fromuserid = fromuserid;
}

public String getRequestsent() {
    return requestsent;
}

public void setRequestsent(String requestsent) {
    this.requestsent = requestsent;
}

public String getRequestaccepted() {
    return requestaccepted;
}

public void setRequestaccepted(String requestaccepted) {
    this.requestaccepted = requestaccepted;
}

}

kovrus commented 8 years ago

@akandach You use the @Transactional annotation, Crate.IO does not support transactions. Could you also show the code of the BaseEntity class?

All in all, there mustn't be any problems with the injection of such simple entities, you also could have seen that from the above-provided code snippets. Please, check the docs/readme of the Spring Crate data project once again.

akandach commented 8 years ago

Here is the BaseEntity. Yes my object model is simple only. No complextypes.

/**

import org.hibernate.validator.constraints.NotBlank; import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Version;

/**

akandach commented 8 years ago

Looks like if we do not set all the values for the given object then i think we have issue.

joemoe commented 8 years ago

hi @akandach, we can confirm this issue. at the moment we are rethinking the whole spring data integration. we should have gone with jpa right away. we won't follow this path. feel free to contribute on this issue, otherwise we'll have to ask you to wait for the jpa integration.

akandach commented 8 years ago

thanks joemoe, when can we expect jpa integration?