注释接口 Transient
Example-1: Transient property
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();
}
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();
}
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();
}
class BookStoreNewestBooksResolver implements TransientResolver<Long, List<Long>>{
...omit code...
}- 另请参阅:
-
可选元素概要
可选元素
-
元素详细资料
-
value
Class<?> valueIf this argument 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 `value` means complex calculation means complex calculation property, You can also view
Formulawhich can be used as simple calcluation property- 返回:
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
- 默认值:
void.class
-