I am having a POJO class which consists of:
– persistent properties,
– transient properties.
While writing HQL I considered both: persistent and transient properties.
I.e. HQL like select persistent_properties,transient_prop from Pojo_classname
is it correct?
Can I write @Basic annotation to transient variables?
No, it’s not correct. A HQL query translates to SQL. An
@Transientproperty is not in the database, so the SQL query won’t be able to query over this property.@Basicand@Transientare contradictory. The first one tells “this property is persistent” and the second one tells “This property is not persistent”.If you’re talking about the Java
transientkeyword, and not about the@Transientannotation, then yes, atransientfield may be queried and annotated with@Basic. Thetransientkeyword has nothing to do with persistence, only with binary serialization of the object.