简体   繁体   中英

Documentation - How do I declare a method transient in hibernate hbm.xml file?

I want to declare a method transient in a hibernate entity, and we are using hbm.xml files for the mappings instead of annotations.

I see sparse mentions online of people declaring fields transient in xml, declaring method transient with annotations, but I cannot find the documentation for declaring methods transient in xml. I see some mentions that if it's not in the hbm.xml file Hibernate will ignore it, but I'd like to confirm.

Where is the documentation for this?

The legacy XML mapping documentation seems to be removed since Hibernate 5.But you can still find its documentation in the Hibernate 4 documentation, section 5 .

And it is true when using hbm.xml , if you don't need to map a field or a method , just do not include it in hbm.xml . I cannot find this behavior is mentioned explicitly in the documentation as I think it is a common sense for people to think it back to the time when there is only legacy XML mapping.

And after introducing annotation mapping , it introduced the features that the mapping fields will be auto-detected by default which does not require to explicitly declare all mapping fields . The differences of this behaviour between legacy XML and annotation mapping are somehow mentioned in the documentation implicitly as follows:

You need to decide which property needs to be made persistent in a given entity. This differs slightly between the annotation driven metadata and the hbm.xml files.

In the annotations world, every non static non transient property (field or method depending on the access type) of an entity is considered persistent, unless you annotate it as @Transient. Not having an annotation for your property is equivalent to the appropriate @Basic annotation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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