问题描述
我有一个POJO类包括:结果
- 持续的性能,结果
- 瞬态特性
I am having a POJO class which consists of:
- persistent properties,
- transient properties.
在写HQL我考虑两:持续性和短暂性。
即HQL像选择persistent_properties,从Pojo_classname transient_prop
While writing HQL I considered both: persistent and transient properties.I.e. HQL like select persistent_properties,transient_prop from Pojo_classname
是正确的?
我可以写 @Basic
标注瞬态变量?
Can I write @Basic
annotation to transient variables?
推荐答案
没有,这是不正确的。一个HQL查询转换为SQL。一个 @Transient
属性是不是在数据库中,所以SQL查询将无法进行查询过这个属性。
No, it's not correct. A HQL query translates to SQL. An @Transient
property is not in the database, so the SQL query won't be able to query over this property.
@Basic
和 @Transient
是矛盾的。第一个告诉此属性是持久的,第二个告诉此属性不是持久性的。
@Basic
and @Transient
are contradictory. The first one tells "this property is persistent" and the second one tells "This property is not persistent".
如果你在谈论有关Java 瞬态
关键字,而不是有关 @Transient
注释,然后是,一个瞬态
字段可以查询并与 @Basic
注释。在瞬态
关键字无关的持续性,只有对象的二进制序列化。
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
. The transient
keyword has nothing to do with persistence, only with binary serialization of the object.
这篇关于注释@Basic瞬态变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!