@Transient not working in hibernate

romil gaurav picture romil gaurav · Oct 7, 2015 · Viewed 7.7k times · Source

I am using hibernate 4.1.9. My code is

@Transient
private String ldapIdTemp;

package is

import javax.persistence.Transient;

Still in hibernate query, it is not working and putting the attribute in the query.

part of query snippet (assetasset0_.ldapIdTemp as ldapIdTemp16_0_, )

I am not sure what I am doing wrong.

Answer

Arpit Aggarwal picture Arpit Aggarwal · Oct 7, 2015

Can you try creating setter and getter for the field and annotate the get method with @Transient, as follows:

private String ldapIdTemp;

 @Transient
 public String getLdapIdTemp() {
    return ldapIdTemp;
 }

 public void setLdapIdTemp(String ldapIdTemp) {
    this.ldapIdTemp = ldapIdTemp;
 }