Can the properties displayed in hbm.xml be temporary?

Suppose I have an object Userlike this:

class User {
    private String login;
    transient private String hashedPassword;
}

I don’t want to ever pass on to hashedPasswordclients, so I am doing this in transition.

This class is displayed by Hibernate, both fields being displayed in hbm.xml.

Is this implementation safe and correct? Will Hibernate correctly store hashedPasswordin the database, load it into objects from the database, store it in the replicated second-level cache and local session cache, etc.?

In word order, transientdoes Hibernate or Level 2 caching respect in any way or completely ignore it?

EDIT . I already have two answers that don't seem to include one specific aspect of the equation. I don't use annotations at all, just XML mappings in hbm.xml. And this Java transient field is OR-mapped to hbm.xml.

+5
source share
3 answers

Unmapped / Transient properties are not saved in sleep mode .

Hibernate understands the meaning of standard java transient modifiers, but it also allows you to annotate properties as transients using the @Transient annotation, if you decide ... Or just completely leave the field from the mapping file.

, , - , " ", .

: , -

hbm.xml

1) - .

POJO

2) Hibernate @Transient:

@Transient
int ignored=0;

3) Hibernate "" :

private transient int ignored =0;

. http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/ .

+7

, Hibernate transient, , .

@Transient Hibernate , , , , Hibernate transient.

:

JPA -

@

, JPA 2.0: " , transient @Transient."

+3

- Hibernate - . TRANSIENT, java. , L2 ..? , hbm.

0

All Articles