@Transient does not work in sleep mode

I am using sleep mode 4.1.9. My code

@Transient private String ldapIdTemp; 

package

 import javax.persistence.Transient; 

In a sleep request, it does not work and places the attribute in the request.

part of the request fragment (assetasset0_.ldapIdTemp as ldapIdTemp16_0_,)

I'm not sure what I'm doing wrong.

+5
source share
2 answers

Can you try creating a setter and getter for the field and annotating the get method with @Transient , as shown below:

 private String ldapIdTemp; @Transient public String getLdapIdTemp() { return ldapIdTemp; } public void setLdapIdTemp(String ldapIdTemp) { this.ldapIdTemp = ldapIdTemp; } 
+7
source

Much depends on how you "integrated" this field into your Entity or class hierarchy. Moreover, the field and access to properties can cause a problem for your setup. See more details.

In your case, I could imagine that you either:

  • mixed field and access property in entity inheritance strategies
  • Use the XML configuration for Hibernate in your application.

In both cases, the JPA 2.0 / 2.1 specification is clearly stated in section 2.3.1:

This is an error if the default access type cannot be determined and the access type is not explicitly specified using annotations or an XML descriptor. The behavior of applications in which to mix the placement of annotations by fields and properties within an entity hierarchy without explicitly specifying Access annotation is undefined.

Please verify that your persistent Entity classes have annotations based on field or property.

+4
source

Source: https://habr.com/ru/post/1233161/


All Articles