@Segment
Marks an interface method to define a reusable SQL fragment. The method name is the fragment name, referenced in other SQL via the @{macro,fragmentName} rule.
Example: reuse a column list via SQL fragment
@SimpleMapper
public interface UserMapper {
@Segment("user_uuid, user_name, login_name, email, register_time")
void userColumns(); // Method name = fragment name
@Insert({"insert into user_info (@{macro,userColumns})",
"values (#{userUuid}, #{name}, #{loginName}, #{email}, #{registerTime})"})
int createUser(UserInfo info);
}
tip
@Segment methods return void — they are never actually called; they only serve as SQL fragment carriers. value supports string arrays.
Properties
| Property | Description |
|---|---|
| value | Required SQL fragment content (supports string arrays, joined with spaces). |