[英]Annotation @Basic to transient variables
I am having a POJO class which consists of: 我有一个POJO课程,其中包括:
- persistent properties, - 持久性,
- transient properties. - 瞬态属性。
While writing HQL I considered both: persistent and transient properties. 在编写HQL时,我考虑了两者:持久性和瞬态属性。 Ie HQL like
select persistent_properties,transient_prop from Pojo_classname
即HQL,例如
select persistent_properties,transient_prop from Pojo_classname
is it correct? 这是对的吗?
Can I write @Basic
annotation to transient variables? 我可以将
@Basic
注释写入瞬态变量吗?
No, it's not correct. 不,这不对。 A HQL query translates to SQL.
HQL查询转换为SQL。 An
@Transient
property is not in the database, so the SQL query won't be able to query over this property. @Transient
属性不在数据库中,因此SQL查询将无法通过此属性进行查询。
@Basic
and @Transient
are contradictory. @Basic
和@Transient
是矛盾的。 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 transient
keyword, and not about the @Transient
annotation, then yes, a transient
field may be queried and annotated with @Basic
. 如果您正在讨论Java
transient
关键字,而不是关于@Transient
注释,那么是的,可以使用@Basic
查询和注释transient
字段。 The transient
keyword has nothing to do with persistence, only with binary serialization of the object. transient
关键字与持久性无关,只与对象的二进制序列化有关。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.