Search code examples
javahibernatejpapersisttransient

Getting Illegal state exception for @Transient property in Hibernate


I have one property in Model class which is having @transient property,I have used this annotation because I don't want it to persist with database. But in the query in DaoImpl class I have used it in select clause. So this gives me :java.lang.IllegalStateException: No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode

What could be the reason? I don't want to remove @transient annotation.

    public class Hello implements Serializable{
    @JsonIgnore
    private String new;

    @Transient
    @JsonIgnore
    private String wanted;

}

query in DaoImpl class

SELECT new,wanted from Hello

Solution

  • You cannot use a transient property inside your query.

    The whole meaning of transient is that DB is not aware of this property