简体   繁体   English

注释@Basic到瞬态变量

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM