lundi 7 mars 2016

Java Hibernate javax.persistence.Transient Annotation on Reflection

I have a simple class like this

public class MyClass
{
   private String fullName;
   javax.persistence.Transient
   private String getFullNameWithPoint(){return this.name+" "+fullName+".";}
}

I iterate all over the fields but i need to know which fields has the javax.persistence.Transient annotation how can i do this?

I have something like this

if(java.lang.reflect.Modifier.isPrivate(field.getModifiers()) && !java.lang.reflect.Modifier.isTransient(field.getModifiers()) && !java.lang.reflect.Modifier.isStatic(field.getModifiers()) && !Collection.class.isAssignableFrom(field.getType()) && !Map.class.isAssignableFrom(field.getType()))

With this condition i know which field has the transient annotation but the java transient

!java.lang.reflect.Modifier.isTransient(field.getModifiers())

But i need to know which fields are market with javax.persistence.Transient Annotation is possible?

Thanks a lot a best regards sorry by my poor english

I cannot modify the signature of the property mean i cannot do this

private transient String fullName;

Thanks a lot.





Aucun commentaire:

Enregistrer un commentaire