8

I have an object in java that have a lot of properties. I want to get it for create a SOAP request dynamically (tags-value).

I need all of this properties not only the first level (I want properties inside others properties).

I see the reflection api in java in this web but only give me the public properties (or declared with getDeclaredFields()) of the object and I have properties in other classes because hibernate get me all values from a DB in FetchType.EAGER

@Version
@Column(name = "VERSION")
private Integer version;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "ID_LUGAR")
public GatLugar gatLugar;

@Column(name = "NUM_ATESTADO")
public Long numAtestado;

@Temporal(TemporalType.DATE)
@Column(name = "FECHA_REGISTRO")
private Date fechaRegistro;

@Temporal(TemporalType.DATE)
@Column(name = "FECHA_HECHO")
private Date fechaHecho;

For example numAtestado with java reflection get it but gatLugar have more properties-values inside and dont have it with reflection.

Sorry for my english im from spain xD

Thanks for all!!

Antonio Sánchez
  • 83
  • 1
  • 1
  • 3
  • possible duplicate of [How to get the fields in an Object via reflection?](http://stackoverflow.com/questions/2989560/how-to-get-the-fields-in-an-object-via-reflection) – Joe Feb 03 '15 at 11:08

1 Answers1

18

You can use:

<YOUR CLASS>.getClass().getDeclaredFields()

And then also use: getDeclaredFields() for the field you got above

roeygol
  • 4,908
  • 9
  • 51
  • 88