Hint
This article is generated by AI translation.
@Segment Annotation
Marks an interface method and defines a SQL snippet.
Example: define and reuse a column list
@SimpleMapper
public interface UserMapper {
// Method name becomes the SQL snippet name
@Segment("user_uuid, user_name, login_name, login_password, email, seq, register_time")
void user_do_allColumns();
// If you use a string array, elements are joined with spaces
@Insert({
"insert into user_info (@{macro,user_do_allColumns})", // use the macro rule to reference the snippet
"values (#{userUuid}, #{name}, #{loginName}, #{loginPassword}, #{email}, #{seq}, #{registerTime})" })
int createUser(UserInfo tbUser);
}
- The
createUsermethod references the SQL snippet defined byuser_do_allColumnsusing the macro rule.
Properties
| Property | Description |
|---|---|
| value | 必选 SQL fragment definition. |