Impetus / kundera

A JPA 2.1 compliant Polyglot Object-Datastore Mapping Library for NoSQL Datastores.Please subscribe to:
http://groups.google.com/group/kundera-discuss/subscribe
Apache License 2.0
903 stars 233 forks source link

Error query and Kundera TimedOutException with Cassandra #940

Open urielcaire opened 7 years ago

urielcaire commented 7 years ago

Hello! I'm having a problem with Cassandra and Kundera. I need to persist a Frame object with arrays to R, G, and B, but I'm having a 'ERROR c.i.c.c.CassandraClientBase - Error while executing query' and then a 'com.impetus.kundera.KunderaException: TimedOutException ()'. The Frame object loads well into memory, but when the data is going to be persisted the terminal shows the first error with the Query, and on final I have TimedOutException. I believe it is something related to the amount of data, because if only the array of R (or one of others) is inserted into the Frame object, nothing is listed in the terminal no error is displayed and the data is written correctly. OBS: my logback.xml just show ERRORS and my show.query is set to false.

my DAO class

imports.....
public abstract class DAO<E>{
        protected EntityManager entityManager;

    public DAO(){
        entityManager = getEntityManager();
    }

    private EntityManager getEntityManager(){
        Map<String, String> props = new HashMap<>();
        props.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0);
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu", props);
        if(entityManager == null)
            entityManager = emf.createEntityManager();

        return entityManager;
    }

        public boolean persist(E object){
        boolean result = true;

        try{
            entityManager.getTransaction().begin();
            entityManager.persist(object);
            entityManager.getTransaction().commit();
        }catch(Exception e){
            System.out.println("DAO - Error during persistence: "+e);
            entityManager.getTransaction().rollback();
            result = false;
        }
        return result;
    }

....
}

Configs:

Java 8 Kundera 3.7 Cassandra 2.2.9 CQL 3.3.1 MAVEN 3.3.9

karthikprasad13 commented 7 years ago

@urielcaire

Can you share your Frame entity?

-Karthik

urielcaire commented 7 years ago

@karthikprasad13 off course!!

// .... javax and java imports....

@Entity
@Table(name = "Frame", schema = "KunderaExamples@cassandra_pu")
public class Frame {

    @Id
    private long keyFrame;

    @Column(name="r")
    private List<Integer> r = new ArrayList<>();

    @Column(name="g")
    private List<Integer> g = new ArrayList<>();

    @Column(name="b")
    private List<Integer> b = new ArrayList<>();

    @Column(name="d")
    private byte[] d;

    @ManyToOne
    private Video video;

    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    @JoinColumn(name = "keyFrame")
    @Column(name = "humanpose")
    private List<HumanPose> humanpose = new ArrayList<HumanPose>();

    public Frame(long keyFrame, List<Integer> r, List<Integer> g, List<Integer> b, byte[] d) {
        this.keyFrame = keyFrame;
        this.r = r;
        this.g = g;
        this.b = b;
        this.d = d;
    }

    public Frame(long keyFrame){
        this.keyFrame = keyFrame;
    }

    public Frame(){

    }

    //...getters and setters...

    public List<HumanPose> getHumanpose() {
        return humanpose;
    }

    public void addHumanPose(HumanPose humanpose) {
        this.humanpose.add(humanpose);
    }

    public void setHumanPose(List<HumanPose> humanPoses) {
        this.humanpose = humanPoses;
    }
}

Obs: My persistence.xml file is setup to create.

urielcaire commented 7 years ago

Also, there are 307200 items in each List !