Skip to main content
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 createUser method references the SQL snippet defined by user_do_allColumns using the macro rule.

Properties

PropertyDescription
value必选 SQL fragment definition.