firebrand icon indicating copy to clipboard operation
firebrand copied to clipboard

update entity with null property @MappedCollection don't remove column in column family

Open rjesususa opened this issue 11 years ago • 6 comments

Well, if I have been updated an entity with NULL value on @MappedCollection property in cassandra database, these column doesn't are removed. it causes the follow exception:

Caused by: java.lang.ClassNotFoundException: at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.firebrandocm.dao.AbstractPersistenceFactory.loadMappedCollection(AbstractPersistenceFactory.java:967) at org.firebrandocm.dao.AbstractPersistenceFactory.loadProperty(AbstractPersistenceFactory.java:934) at org.firebrandocm.dao.impl.hector.HectorPersistenceFactory.loadLazyPropertyIfNecessary(HectorPersistenceFactory.java:537) at org.firebrandocm.dao.ClassMetadata$2.invoke(ClassMetadata.java:532) at br.com.mca.comissionamento.mcadominio.server.persistence.domain.TermoAberturaProjeto_$$javassist_23.getDocumentos(TermoAberturaProjeto$$_javassist_23.java)

When I try access the list property: tap.getDocumentos()

tap is this entity: public class TermoAberturaProjeto extends EntityBase { private static final long serialVersionUID = -8093038817100592845L;

@Key
private String key;

@MappedCollection
private List<DocumentoReferencia> documentos;

... }

rjesususa avatar Jul 30 '13 21:07 rjesususa

While the reported exception is cryptic and can be improved firebrand maps collections by composing a String containing the class name and target id and does not support at this time discovering removed relationships outside of firebrand. Can you provide a test case for this use case? I'll be happy to look into it once I understand more what the actual case and provide either better exception handling for missing collection items or a fix for it.

On Tue, Jul 30, 2013 at 11:48 PM, Raneves [email protected] wrote:

Well, if I have been updated an entity with NULL value on @MappedCollection property in cassandra database, these column doesn't are removed. it causes the follow exception:

Caused by: java.lang.ClassNotFoundException: at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:169) at org.firebrandocm.dao.AbstractPersistenceFactory.loadMappedCollection(AbstractPersistenceFactory.java:967) at org.firebrandocm.dao.AbstractPersistenceFactory.loadProperty(AbstractPersistenceFactory.java:934) at org.firebrandocm.dao.impl.hector.HectorPersistenceFactory.loadLazyPropertyIfNecessary(HectorPersistenceFactory.java:537) at org.firebrandocm.dao.ClassMetadata$2.invoke(ClassMetadata.java:532) at br.com.mca.comissionamento.mcadominio.server.persistence.domain.TermoAberturaProjeto_$$javassist_23.getDocumentos(TermoAberturaProjeto$$_javassist_23.java)

When I try access the list property: tap.getDocumentos()

tap is this entity: public class TermoAberturaProjeto extends EntityBase { private static final long serialVersionUID = -8093038817100592845L;

@Key private String key;

@MappedCollection private List<DocumentoReferencia> documentos;

... }

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

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

raulraja avatar Jul 30 '13 22:07 raulraja

Raul, the updated is execute on firebrand method. look this example with TermoAberturaProjeto class:

//my dao retrieve the entity from DB. TermoAberturaProjeto tap = dao.get(TermoAberturaProjeto.class, id); tap.setDocumentos(null); // or a ArrayList size equals 0 dao.update(tap); // execute method persist of firebrand.

on it's case, the column reference of property documentos(List with @MappedCollection) don't is removed on cassandra and the value of the column is empty. => (column=documentos, value=, timestamp=1375220612449000)

so, i have exceptions when try execute the simple method get of my atribute.

like this:

TermoAberturaProjeto tap = dao.get(TermoAberturaProjeto.class, id); tap.getDocumentos(); // this throws exception when I try access the list property.

rjesususa avatar Jul 30 '13 22:07 rjesususa

I see, it is indeed a bug that an exception is thrown in this case. I will look into it and fix it as soon as I have some time. Thanks for reporting it! On Jul 31, 2013 12:29 AM, "Raneves" [email protected] wrote:

Raul, the updated is execute on firebrand method. look this example with TermoAberturaProjeto class:

//my dao retrieve the entity from DB. TermoAberturaProjeto tap = dao.get(TermoAberturaProjeto.class, id); tap.setDocumentos(null); // or a ArrayList size equals 0 dao.update(tap); // execute method persist of firebrand.

on it's case, the column reference of property documentos(List with @MappedCollection) don't is removed on cassandra and the value of the column is empty. => (column=documentos, value=, timestamp=1375220612449000)

so, i have exceptions when try execute the simple method get of my atribute.

like this:

TermoAberturaProjeto tap = dao.get(TermoAberturaProjeto.class, id); tap.getDocumentos(); // this throws exception when I try access the list property.

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

raulraja avatar Jul 31 '13 00:07 raulraja

Hello Raul, are you ok?

You'll fix this issue?

fzoro avatar Sep 19 '13 14:09 fzoro

?

rjesususa avatar Sep 19 '13 19:09 rjesususa

@fabiozoroastro @Raneves I have been very busy lately and not had much time to dedicate to this issue. If you need an immediate fix I'll be happy to review any PR's. Thx

raulraja avatar Sep 20 '13 21:09 raulraja