Is there any difference between 'static transients' and 'transient Type aField' declaration for GORM?

StackOverflow https://stackoverflow.com/questions/12462205

문제

Let us consider two Grails domain example classes.

1st class:

class Person {

    String name
    Integer counter = 0

    static transients = ['counter']
}

2nd class:

class Vehicle {

    String name
    transient Integer counter = 0
}

Will there be any difference in GORM persistence or domain class behaviour for the Integer counter field between classes Person and Vehicle?

EDIT: I know that Person class is the good way to do it as referenced by Grails docs. However I would prefer the Vehicle class way as it seems to be more obvious and easier not to overlook when reading a code.

도움이 되었습니까?

해결책

The two mechanisms define different kinds of "transience". static transients defines bean properties that should not be mapped to the database by Hibernate, whereas the transient keyword denotes a field that should not be saved by the Java object serialization mechanism (e.g. when using webflow). They both have their uses in different situations.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top