注释接口 Transient
Example-1: Transient property
If no argument of this annotation is not specified, the decorated property is a transient property, that means you can only get and set(by draft) it and ORM will ignore it
Otherwise, the decorated property is a complex calculation property that means you can add it into ObjectFetcher and jimmer will load it in query.
`@Transient` with argument means complex calculation means complex calculation property,
You can also view Formula which can be used as simple calculation property
Example-1: Transient property ignored by ORM
public class BookStore {
...omit other properties...
@Transient
String userData();
}
Example-2: Complex calculation property whose return type is scalar type
public class BookStore {
...omit other properties...
@Id
long id();
@Transient(BookStoreAvgPriceResolver.class)
BigDecimal avgPrice();
}
// If `TransientResolverProvider` of `SqlClient` is `SpringTransientResolverProvider`,
// please decorate the resolver class by 'org.springframework.stereotype.Component'
@Component
class BookStoreAvgPriceResolver implements TransientResolver<Long, BigDecimal>{
...omit code...
}
Example-3: Complex calculation property whose return type is entity type
public class BookStore {
...omit other properties...
@Id
long id();
@Transient(BookStoreMostPopularAuthorResolver.class)
Author mostPopularAuthor();
}
// If `TransientResolverProvider` of `SqlClient` is `SpringTransientResolverProvider`,
// please decorate the resolver class by 'org.springframework.stereotype.Component'
@Component
class BookStoreMostPopularAuthorResolver implements TransientResolver<Long, Long>{
...omit code...
}
Example-4: Complex calculation property whose return type is list of entity type
public class BookStore {
...omit other properties...
@Id
long id();
@Transient(BookStoreNewestBooksResolver.class)
List<Book> newestBooks();
}
// If `TransientResolverProvider` of `SqlClient` is `SpringTransientResolverProvider`,
// please decorate the resolver class by 'org.springframework.stereotype.Component'
@Component
class BookStoreNewestBooksResolver implements TransientResolver<Long, List<Long>>{
...omit code...
}- 另请参阅:
-
可选元素概要
可选元素
-
元素详细资料
-
value
Class<?> value- 返回:
- A class implements
`org.babyfish.jimmer.sql.TransientResolver` of jimmer-sql or
`org.babyfish.jimmer.sql.kt.KTransientResolver` of jimmer-sql-kotlin.
The first type argument of `TransientResolver` should the `ID` of declaring entity type
- If the current calculation property returns simple type, the second type argument of `TransientResolver` should be return type of current property
- If the current calculation property returns entity type, the second type argument of `TransientResolver` should be `ID` of target entity type
- If the current calculation property returns a list whose element type is entity type, the second type argument of `TransientResolver` should be a list whose element type is `ID` of target entity type
ref()
- 默认值:
void.class
-
ref
String refIn multi-module project, the resolver type may be declared in another module so thatvalue()cannot be specified, please use this argumentThis argument can only be used with spring, it means the spring bean name of resolver object.
- 返回:
- The spring bean name
- 默认值:
""
-