Talk about my understanding of mybatis and jpa

In fact, to admit that a thing with a long time will have a psychological habit. mybatis and jpa, two persistence framework. From the bottom to the usage is different. But to achieve the same functionality. So it has always been controversial. Perennial removed from the major technology qq exchange group. Jpa seen diehard powder have seen the hardcore mybatis. Less than two years of work experience as a small rookie, you let me analyze source code, the underlying implementation speaking what I could not speak of. Only as a user, to talk about their understanding of these two frameworks.

Talk about my understanding of the mybatis and jpa
First, know the jpa formerly known ssh in h -> Hibernate. I still remember when learning to explain it generated Hibernate: do not want to write a sql statement to the database to operate lazy willing to develop a framework founder, in fact, worth enough to remember the wonderful work. And now jpa, I think the subject matter is indeed in the implementation of this concept. You have to admit, jpa really simple and convenient and practical for simple single-table queries. But at the same time, related to multi-table queries and complex, at least so far, to complex queries or split into multiple simple queries, or rather a direct nativeQuery = true to the original query. If these two failed to meet the needs of your business, I can not make up your design to the conclusion that there is a problem, but such a complex business logic, as white, I really can not give you a suggestion.

Then comes mybatis, forgive me relatively late entry. I started to learn java he had already seen. He seems to have heard of the predecessor ibatis, but is less specific understanding. The use of terms, in the era of the boot has not yet released, mybatis was once essential skills for every programmer. When mapper mapping new to my eyes is simply magical. Can be considered by more than six months, how many have a certain understanding. Here's the basic use not introduced, anyway, I have been applied also basically crud. To the point of not more than profound. For multi-table queries can only say that indeed more support. Especially in the case of multi-table business logic mostly associated, mybatis definitely be more suitable than jpa. Whether or future maintenance operations are easy to change a lot.

I might say that we still do not understand when to use and when jpa with mybatis. I For example: business now A, B, C, D four tables. If you each table will be used in the business, we need to have a separate CRUD, although there is some relationship, but this is more appropriate with jpa. ABCD four java entity does not say that each entity corresponds to a repository. Then write repository layer of crud. However, if the service A, B, C, D four tables. The four is an association, you hardly alone on the A, B, C to operate, but also emerged with D, so this time using jpa will be very troublesome, because you still have four four entities repository. Four in an interface repository one by one called once. Although the business logic to complete, but complex and cumbersome. Also consider atomic or something. So this time with mybatis more appropriate.

Talk about my understanding of mybatis and jpa of
fact, he said this is probably about what kind of business which should be used in thinking there should be a distinction between simple. But often many projects at once can not tell the difference of what belongs to. We still need specific judgment. Although the work was more than a year, but I went through outsourcing experience multiple items Tell me, do not believe the so-called "big brother so and so" just give you advice. (I mean those who do not know the specific business even give you suggestions jpa good or mybatis good kind. If that is the big brother and willing to in-depth analysis and answer for your project, it is still worthy of reference) because once before in my boss gave me a small project independently when I chose to consult the group of chiefs. I remember very clearly when the big brother to the opinion is mybatis. Mybatis said a lot of advantages. Then I naturally spent. The results Well, we can think of one person I can finish the project there will be more small businesses and more concise. Although the use of mybatis also done. But now I think about it, if replaced by jpa will certainly be more rapid and easy development. I say this experience is absolutely no other meaning, just want to tell you how business-like or know best. Many times we ask may not be comprehensive, so people give advice is not very suitable.

Then there are some extra things. For example, the attitude of spring family. I do not know you have not told me the same mass psychology. A jar package. As long as this is org.springframework.boot packet, it is more trust. After all, there are so huge family backed itAnd boot really is a package of more specific~ Anyway vaguely remember that spring to create projects, configure this and that, under the occasional sloppy also reported a mistake. Setting up a structure for a while (I was probably also be more vegetables, but do you want to configure something) And now, spring boot, almost created, dependent on what you can run lead. It is really quite easy. Convenient to group some time ago in a child asked a spring configuration, I actually feel a little not rememberHeyspring boot multi-purpose, and people with regard to the sb ~ ~ ~ Haha, kidding, do not take it seriously. Anyway, now the height of the package code Let us use what is more simple. The boot of jpa package, anyway, I personally think that in a simple configuration above, except in the database connection in the configuration file and then add a data-jpa-dependent, and get it. This is also personally like jpa point. Deployment is really simple. And very comprehensive official document. Also continued maintenance updates. I think just from the point of view of the spring, jpa it is worth a try. Of course, this is a personal state of mind, but if you are a novice practiced hand in their own projects, I still recommend jpa.

Talk about my understanding of mybatis and jpa the
right, and then look at additional Amway, this would involve the use of personal experience. Previously, only mybatis have code generator, so for this reason there was a time I also prefer to use mybatis. But now jpa has also been a code generator. From the table to the entities and entity table can be automatically generated. I do not knock it white hand ~~~ (ps: because I have done this so this reminder white like me Xiaopen friends you know, can sweep). As for the use of the code generator, as long as you know this concept can be found to Baidu usage, here I will not say more. Really I do not know can ask me if I would see a return, although I think I find it as their own Baidu.

And then say a digression, in fact jpa and mybatis are necessary to learn. Because the project will encounter a variety, so both merits and demerits. There is, if they did not voice, it is best to let a parent what to use what. note! I'm talking about the best. If your team atmosphere is good, then more willing to accept the leadership of any comments you out with practical considerations do have different views can be put forward. Otherwise honestly listen to the command bar. Do not worry about how you think is unreasonable. I'm not promote anything negative concept. And in a team and point you might consider not the same as leadership under consideration. Or that you know is not comprehensive and so on. No need to have to own so-called correct and then finally you do not get happy. Especially the last result also may not think you want to be. They are doing technology, and self-righteous little or own opinion is normal. But remember that people still want to humble. To tell you a story actually happened.

Talk about my understanding of mybatis and jpa of
our team has been a handwriting interface documentation and manual maintenance. Indeed there are many document generation tools, I also used the swagger done a demo, but the team and some people will not use, but in fact a lot of trouble to maintain them (probably useless habit of trouble, this is not essential), and then our projects are relatively small. So leaders said on manual maintenance interface documentation of it. Many then came some time ago internship child may be very hard indeed to learn, contact technology. Then start doing all day full of conscious effort to work overtime in the company to learn the kind of late. And later he opened a project, see our child maintenance manual interfaces may be felt relatively low, so with our leadership suggested swagger. Then we headed back very politely that he learn to understand, think again, first by hand so maintaining it. Ever since then we have to manually change the interface, so how how he would say, Bala Bala. Once our team is focused on working relatively long time because the interface of a docking brother did a good butt, so the test of time a little bug, the child began to complain that how how bad handwritten document. . Then we headed broke out, Pilipala meal reprimanded, probably means that people here who have experience than he, ah, ah what he is superior, why do not change because they want to be familiar with the rear end of the front frame is not necessary. . Then after that the child silence more, do not know what epiphany or that angry. Soon afterwards the boy left. Resign or be discouraging also I do not know. In fact, just look at this story, a swagger thing, can not tell who is right. Have to say, one of our outsourcing company, demand is certainly deal done on the line, the boss do not want to take the time to learn some of the employees did not need skills. Small boy's point of view, an intern but insisted no decision assertiveness. This can be considered a workplace experience of it~ I spoke beside the point~

Talk about my understanding of the mybatis and jpa
anyway core words ":

1, jpa and mybaits advantages and disadvantages.

2, the use of which is suitable to be combined with specific business analysis.

3, when you do not have the right to decide, it is best to let the leadership of what what.

For our technical staff is concerned, should be familiar with the two, it will be used.

Talk about my understanding of mybatis and jpa

Guess you like

Origin blog.51cto.com/14416052/2422244