I have a class such as:
Code:
public class A implements Serializable{
........
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "COLUMN_ID")
private B b;
........
}
public class B implements Serializable{
........
@Column(name = "B_NAME", nullable = false, length = 135)
private String name;
........
}
If I try:
Code:
a.getB().getName()
The correct value is returned. What I'm trying to do though is match the property values with elements in an XML file. So for this I thought to use ClassMetadata.getPropertyValue. However,
Code:
SessionFactory factory = HibernateUtil.currentSession().getSessionFactory();
ClassMetadata classMetadata = factory.getClassMetadata(HibernateUtil.currentSession().getEntityName(a.getB()));
Object value = classMetadata.getPropertyValue(a.getB(), "name", EntityMode.POJO);
returns a NULL value. ClassMetadata.getPropertyNames() does return all the list of properties. I've tried Hibernate.initialize(a.getB()) and that didn't work either.
Am I using the getPropertyValue method incorrectly? Am I doing something else wrong?
Thanks for the help.