question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adds the ability to complement each other with attributes of annotations and XML tags

See original GitHub issue

Feature 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:open
  • Created a year ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
awxiaoxian2020commented, May 23, 2022

@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.

1reaction
awxiaoxian2020commented, May 23, 2022

Based on community comments, should I classify this issue as a documentation issue and submit an explicit hint? (I don’t see the relevant instructions, but I’m not sure if this was intentional)

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found