firebrand icon indicating copy to clipboard operation
firebrand copied to clipboard

not have a CQLMappedEntityValueConverter on List valueConverters.

Open rjesususa opened this issue 11 years ago • 10 comments

not have a CQLMappedEntityValueConverter on list valueConverters of QueryBuilder.class after initialize application on first execution of query.

then my query return a NULL object, but I have expected a entity.

in second call of query, the class CQLMappedEntityValueConverter is present in list valueConverters, returning my object correctly.

rjesususa avatar Jun 19 '13 20:06 rjesususa

Can you provide code and how you are initializing the factory?

On Wed, Jun 19, 2013 at 10:00 PM, Raneves [email protected] wrote:

not have a CQLMappedEntityValueConverter on list valueConverters of QueryBuilder.class after initialize application on first execution of query.

then my query return a NULL object, but I have expected a entity.

in second call of query, the class CQLMappedEntityValueConverter is present in list valueConverters, returning my object correctly.

— Reply to this email directly or view it on GitHubhttps://github.com/47deg/firebrand/issues/25 .

Raúl Raja Martínez Co-founder @ 47 Degrees h: http://raulraja.com w: http://47deg.com t: http://twitter.com/raulraja

raulraja avatar Jun 19 '13 20:06 raulraja

the follow code initializing the factory:

                persistenceFactory = new HectorPersistenceFactory();
                persistenceFactory.setAutoDiscoverHosts(true);
                persistenceFactory.setDefaultConsistencyLevel(ConsistencyLevel.ALL);
                persistenceFactory.setEntities(entities);
                persistenceFactory.setClusterName(getProperties().getProperty("clusterName"));
                persistenceFactory.setDefaultKeySpace(getProperties().getProperty("defaultKeySpace"));
                persistenceFactory.setContactNodes(new String[]{ getProperties().getProperty("contactNodes")});
                persistenceFactory.setThriftPort(Integer.parseInt(getProperties().getProperty("rpcPort")));
                persistenceFactory.setPoolName(getProperties().getProperty("poolName"));
                persistenceFactory.setDebug(Boolean.parseBoolean(getProperties().getProperty("debug")));

                persistenceFactory.init();

rjesususa avatar Jun 19 '13 20:06 rjesususa

Query query = Query.get(QueryBuilder.select(QueryBuilder.allColumns(), QueryBuilder.from(entity.getClass()), QueryBuilder.where( QueryBuilder.eq("project", project) )));

project is a column family mapped in my class.

rjesususa avatar Jun 19 '13 20:06 rjesususa

the atribute "entities" is a list of class

rjesususa avatar Jun 19 '13 21:06 rjesususa

any atualization?

rjesususa avatar Jun 27 '13 20:06 rjesususa

Can you also send the Entity including all mappings?

On Thu, Jun 27, 2013 at 10:09 PM, Raneves [email protected] wrote:

any atualization?

— Reply to this email directly or view it on GitHubhttps://github.com/47deg/firebrand/issues/25#issuecomment-20151472 .

Raúl Raja Martínez Co-founder @ 47 Degrees h: http://raulraja.com w: http://47deg.com t: http://twitter.com/raulraja

raulraja avatar Jun 28 '13 22:06 raulraja

public class Empresa extends EntityBase { private static final long serialVersionUID = -2117279214808111578L;

@Key
private String key;

@Column(indexed = true)
private String nomeEmpresa;

@Mapped
private SegmentoProjeto segmento; // I have use this for query parameter

@Column(validationClass = BytesType.class)
private byte[] logoTipoEmpresa;

/**
 * @return the key
 */
public String getKey()
{
    return key;
}

/**
 * @param key
 *            the key to set
 */
public void setKey(String key)
{
    this.key = key;
}

/**
 * @return the nomeEmpresa
 */
public String getNomeEmpresa()
{
    return nomeEmpresa;
}

/**
 * @param nomeEmpresa
 *            the nomeEmpresa to set
 */
public void setNomeEmpresa(String nomeEmpresa)
{
    this.nomeEmpresa = nomeEmpresa;
}


/**
 * @return the segmento
 */
public SegmentoProjeto getSegmento()
{
    return segmento;
}

/**
 * @param segmento the segmento to set
 */
public void setSegmento(SegmentoProjeto segmento)
{
    this.segmento = segmento;
}

/**
 * @return the logoTipoEmpresa
 */
public byte[] getLogoTipoEmpresa()
{
    return logoTipoEmpresa;
}

/**
 * @param logoTipoEmpresa the logoTipoEmpresa to set
 */
public void setLogoTipoEmpresa(byte[] logoTipoEmpresa)
{
    this.logoTipoEmpresa = logoTipoEmpresa;
}

public String getId()
{
    return key;
}

public void setId(String id)
{
    key = id;
}

}

in my query i use segmento in clausule where.

Query query = Query.get(QueryBuilder.select(QueryBuilder.allColumns(), QueryBuilder.from(Empresa.class), QueryBuilder.where( QueryBuilder.eq("segmento", segmento) )));

entity segmento is:

public class SegmentoProjeto extends EntityBase {

private static final long serialVersionUID = -8185147223966996268L;

@Key
private String key;

@Column(indexed = true)
private String nomeSegmento;


/**
 * @return the key
 */
public String getKey()
{
    return key;
}

/**
 * @param key the key to set
 */
public void setKey(String key)
{
    this.key = key;
}

/**
 * @return the nomeSegmento
 */
public String getNomeSegmento()
{
    return nomeSegmento;
}

/**
 * @param nomeSegmento the nomeSegmento to set
 */
public void setNomeSegmento(String nomeSegmento)
{
    this.nomeSegmento = nomeSegmento;
}

public String getId()
{
    return key;
}

public void setId(String id)
{
    key = id;

}

}

rjesususa avatar Jul 01 '13 20:07 rjesususa

What is the code that you are using to pass the query to the factory and retrieve the List of objects?

raulraja avatar Jul 01 '13 21:07 raulraja

Query query = Query.get(QueryBuilder.select(QueryBuilder.allColumns(), QueryBuilder.from(Empresa.class), QueryBuilder.where( QueryBuilder.eq("segmento", segmento) )));

response = getPersistenceFactory().getSingleResult(Empresa.class, query);

rjesususa avatar Jul 02 '13 11:07 rjesususa

is important execute this query on first time after startup server application.

rjesususa avatar Jul 03 '13 17:07 rjesususa