Adds the ability to complement each other with attributes of annotations and XML tags
See original GitHub issueFeature Request
Is your feature request related to a problem?
No.
Describe the feature you would like.
In the current version 3.5.9, the configuration of the xml tag and the annotation of the java class cannot complement each other. If the following configuration is used, the configuration in @Option
will be invalid.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.mapper.TestMapper">
<insert id="insertTest">
insert into test_table (column_a, column_b)
VALUES (#{object.columnA}, #{object.columnB})
</insert>
</mapper>
@Mapper
public interface TestMapper{
@Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "object.id")
void insertTest(@Param("object") TestPO object);
}
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TestPO{
private Long id;
private String columnA;
private String columnB;
}
The current Mybatis version can only make the corresponding operations all located in xml tags or all in Java class annotations, like the following.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.mapper.TestMapper">
<insert id="insertTest" useGeneratedKeys="true" keyProperty="object.id" keyColumn="id">
insert into test_table (column_a, column_b)
VALUES (#{object.columnA}, #{object.columnB})
</insert>
</mapper>
I think this can be handled appropriately, I don’t seem to have flipped through similar discussions.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
16.11 Annotation-based controller configuration - Spring
The type-level @SessionAttributes annotation declares session attributes used by a specific handler. This will typically list the names of model attributes ...
Read more >Chapter 17 Binding between XML Schema and Java Classes
Illustrates how to use the annotation @XmlAttribute to define a property or field to be handled as an XML attribute. XmlRootElement Example. Illustrates...
Read more >XML Schema Part 0: Primer Second Edition - W3C
The fixed attribute is used in both attribute and element declarations to ensure that the attributes and elements are set to particular values....
Read more >Spring AOP Example Tutorial - Aspect, Advice, Pointcut ...
All the above AOP annotations are defined in ... you are using some other IDE, you can simply add it in the spring...
Read more >Tools attributes reference | Android Studio
This attribute works the same as the @TargetApi annotation in Java code: it lets you specify the API level (either as an integer...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@linghengqian you know the mapper may be complex and the xml can give more config. And I think we should give all details in one context. As there are no principle to how to simplify the xml or seperate them(xml and annotation) appropriately.
if we add the context for
whether valid for the mixture of the specified xml and annotation
, there are too many combinations, I don’t know whether we should add contents for this in the doc.@harawata This is a doc update request. Maybe he want to get the tips when he use the xml and annotation at the same time. What do you think?