views:

24

answers:

1

I need to find a way of taking a hibernate object and discovering at runtime all of the getter methods that relate to persistable fields. I'm using annotations in the classes but have previously had difficulties working with them (I ran into a 2 year old bug the java developers still haven't fixed).

Does anyone know how I can do this please, ideally without using annotations? Thanks.

PS - What I'm trying to do here is to update a new object with values from an existing object dynamically.

+1  A: 

This should be possible using o.h.SessionFactory#getClassMetadata(Class) to obtain the o.h.m.ClassMetadata of your Entity which exposes a getPropertyNames() method allowing to Get the names of the class' persistent properties.

Pascal Thivent
Great. Thanks. I hadn't seen that.
Michael Jones
That looks useful, I can probably use that for some entity interceptors / listeners.