HIbernateBeanReplicator

127 views
Skip to first unread message

Rima T Desai

unread,
Jul 7, 2009, 8:26:02 AM7/7/09
to beanlib
I am working on a application which uses hibernate. I am using
hibernatebeanreplicator to convert the proxy data from hibernate to
null values. I want to just make few variables to null rather than
making the whole class null. how can it be achieved.

I am providing an example here.

Class A {

B b;

}

class B {

int id;
String name;

}

When i am fetching A it makes the object of B as null. I want to make
just name of B to null as i need to use the id from class B.

Here is what i am using to convert the proxy data .



HibernateBeanReplicator replicator = new Hibernate3BeanReplicator
() .initCustomTransformerFactory(conversionUtil.new Factory()); return
replicator.copy(src);

}

public class LazyHibernateCustomBeanTransformer implements
CustomBeanTransformerSpi {
public <T> boolean isTransformable(Object from, Class<T>
toClass,
PropertyInfo propertyInfo) { // apply custom
transformation for
// the uninitialized properties
return !Hibernate.isInitialized(from);
}

public <T> T transform(Object in, Class<T> toClass,
PropertyInfo propertyInfo) {
return null;
}
}

/** The factory for a {@link LazyHibernateCustomBeanTransformer}. */
public class Factory implements CustomBeanTransformerSpi.Factory {
public CustomBeanTransformerSpi newCustomBeanTransformer(
BeanTransformerSpi contextBeanTransformer) {
return new LazyHibernateCustomBeanTransformer();
}


}

Is there a method or way in beanlib to meet my requirement.

Thanks in advance,

Rima

Hanson Char

unread,
Jul 7, 2009, 9:31:38 PM7/7/09
to bea...@googlegroups.com
Do A and B have getter and setter methods ?
Reply all
Reply to author
Forward
0 new messages