firebrand
firebrand copied to clipboard
not have a CQLMappedEntityValueConverter on List valueConverters.
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.
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
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();
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.
the atribute "entities" is a list of class
any atualization?
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
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;
}
}
What is the code that you are using to pass the query to the factory and retrieve the List of objects?
Query query = Query.get(QueryBuilder.select(QueryBuilder.allColumns(), QueryBuilder.from(Empresa.class), QueryBuilder.where( QueryBuilder.eq("segmento", segmento) )));
response = getPersistenceFactory().getSingleResult(Empresa.class, query);
is important execute this query on first time after startup server application.