Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you give me a hint about automatic generation? #1070

Closed
courage0916 opened this issue Oct 5, 2023 · 5 comments
Closed

Can you give me a hint about automatic generation? #1070

courage0916 opened this issue Oct 5, 2023 · 5 comments

Comments

@courage0916
Copy link

courage0916 commented Oct 5, 2023

Firstly, I'm sorry for not responding in a timely manner due to network issues.

I previously raised the issues of 1061,Ask why not generate templates and more models.
Jeffgbutler answered me,can read his previous blogs and list his viewpoints,I have gained something.
previous github link:#1061

However, I still have doubts。
Let me explain the usage scenarios of my program.
In the program, due to display reasons, the original data 0/1 is stored in the Po layer. However, in order to display the processed data yes/no to the user, the VO layer was born. Sometimes, the fields in the VO and Po layers are exactly the same, but most of the time, the fields in the VO layer are more than those in the Po layer. Additionally, the VO field may have fields that do not match the fields in the Po layer and require logical conversion.
The same goes for the dto 、query layer, which is a compromise made for display.
Because without detailed partitioning, users acquire too much redundant data. For example, if the user only needs to look at fields A and B, and the program also shows the C field to the user, this situation is not safe. Good program data should have permissions.
In addition, when initializing controllers and services, they are similar and can actually be extracted. Spring is doing this by opening up the Spring Data jpa and Spring Data Rest frameworks, defining a universal rest style basic plugin that can quickly develop a simple web.
However, I feel that it's not very flexible, so I used mybatis.
The usage of my project seems to be somewhere between the anemia model and the rich domain model.
I want the flexibility and simplicity of MyBatis, and I also want to enrich the basic transformation capabilities of models to cope with the transformation of different models. I need the concise and accurate presentation of different models, and I don't want to write too much code that focuses on models because it doesn't make much sense.

So, I need to use mybatis gen.
Mybatis gen simplifies the pressure on program po and jdbc layers,I also want mybatis gen to simplify the pressure on the vo, query, dto, service, and controller layers.
I am using mybatis dynamic SQL, and after a period of use, I have felt the charm of mybatis dynamic SQL
When I was using mybatis gen to generate code, I couldn't find an open interface to generate the mybatis dynamic SQL model.
Therefore, I would like to ask again in the hope of seeking help.

@jeffgbutler
Copy link
Member

MyBatis Generator can generate code for MyBatis Dynamic SQL:

  <context id="dsql" targetRuntime="MyBatis3DynamicSql">
    ...
  </context>

As for your other application objects, you can write a plugin for MyBatis generator that can generate virtually any kind of code, but you would need to write that plugin. Here's an introductory page on writing plugins: https://mybatis.org/generator/reference/pluggingIn.html

@courage0916
Copy link
Author

MyBatis Generator can generate code for MyBatis Dynamic SQL:

  <context id="dsql" targetRuntime="MyBatis3DynamicSql">
    ...
  </context>

As for your other application objects, you can write a plugin for MyBatis generator that can generate virtually any kind of code, but you would need to write that plugin. Here's an introductory page on writing plugins: https://mybatis.org/generator/reference/pluggingIn.html

ok,I'll take a look at the document first. I tried before and successfully generated the po and mapper in MyBatis3Dynamic Sql format, but I couldn't find the corresponding method to generate other modules

@courage0916
Copy link
Author

courage0916 commented Oct 8, 2023

Turn off 1071, it seems like I can't turn it off. Next time I ask a question, I will throw out all the questions at once
#1071

Do you have plans in the future to allow MyBatis3Dynamic Sql to customize annotations?

@courage0916
Copy link
Author

MyBatis Generator can generate code for MyBatis Dynamic SQL:

  <context id="dsql" targetRuntime="MyBatis3DynamicSql">
    ...
  </context>

As for your other application objects, you can write a plugin for MyBatis generator that can generate virtually any kind of code, but you would need to write that plugin. Here's an introductory page on writing plugins: https://mybatis.org/generator/reference/pluggingIn.html


Doesn't it mean implementing the PluginAdapter interface and then overriding the method can be called? Why did I make an error during execution? Is there any operational error?
image
image
image
image

@jeffgbutler
Copy link
Member

I recommend that you read some example code - there are many plugins on GitHub. This repo has several examples: https://github.com/dcendents/mybatis-generator-plugins

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants