I am very sorry, 1th about "abc" = = "ABC" return false is I was mistaken, in Java is returned true, I did not experiment to say so, very sorry. The reason is that, because I do not remember what kind of, because I used the = = string comparison, the results did not return the results I want, and then ask the elderly, the old people on the admonition: it is best to use equals to compare, and do not use = =, so there is this feeling.
Well, I know it's a lot of people who can't resist making bricks or expressing disapproval, and I accept it.
When I encounter problems, find some Java friends to help, there is a solution, I would like to say that can not solve the situation, most of them will say: "How can you do so?" This is not possible, you first in the thinking on the wrong, we have never done so. "For example," We rarely use stored procedures, and you use so many stored procedures, I recommend that you use Hibernate code to implement your business instead of using stored procedures ", the problem is that when I run into some situations when I have a hibernate stored procedure, When I was a friend of Java I couldn't solve it, he said.
Java developers also like to say: this should not be done by the JDK or a framework, but should be brave, hardworking, intelligent you to write the implementation.
Here are some of the problems I encountered when I was developing a Java project, and there may be some wrong places to read.
Encountered a lot of problems, a time can not be taken out all the discussion, just a few lists.
1. "ABC" = "abc" returned the result is false, many beginners Java in this problem is a lot of waste of time, because it will be very confident that this will return true, there is no idea that the original problem here. Online to see a post discussed this question, say what Java is a purely object-oriented language, = = operator is the comparison of addresses and so on, and "ABC" is a reference, so you can not use the = = operator to compare, but should use the Equals method to compare, will make this mistake, mostly because their foundation is not strong , but still the Java is not. I see a person said an example, very can express my feelings, that is to say: One day I went to a restaurant, because the restaurant door has a pool of water, resulting in slippery road, I accidentally fell, so I came to the restaurant manager, held accountable, the restaurant manager told me that this is because I walk the wrong posture, So slipped and fell, nothing to do with the restaurant.
2. Why not Get;set; attribute, instead of using getxx (); Setxx () method instead, does reflection not cost?
I know of struts\spring\hibernate in a lot of this way, such as the Vo object in struts, if there is a getusername (), in the page can be used <s:property value= "username "/> to take the value, the middle I think it is to use reflection to find the GetUserName () method, and then get its value, the same spring\hibernate also used in a lot of this way, I would like to ask, reflection is not very inefficient?"
3. Make a custom label and write your own TLD configuration file, sometimes read some Java related books mentioned in the 0 configuration, I feel very ridiculous, do not know the so-called 0 configuration of the spirit exactly where? Perhaps writing a configuration file is not that difficult, but the key problem is that technically the TLD is obviously not, ah, the TLD inside the main description of what the tag name has what attributes, what type, the information can be fully represented in the class, As long as the class that implements the tag interface is automatically recognized as a custom label is that not good? By identifying what getxx () is in the class, Setxx (); (A better solution is to have get;set; attributes) to determine which properties of this custom tag, and what type is it? Why do I have to superfluous a TLD configuration file?
Another problem is, if I write a MyTag class, inherit a custom label class, I also write a corresponding TLD configuration for mytag, I do not know if there are any other developers will inherit my MyTag, perhaps even if I warmly welcome others to inherit my MyTag, But when others see me in the MyTag nearly thirty or forty Getxx (); Setxx (), then think of it as a sign of the corresponding TLD configuration file.
4. Data access in my opinion, it should be a very simple thing, simply to execute SQL statements, complex, and then add entity mapping, all the framework to solve the problem, the first is to be easy to use, after using Hibernate, I feel it is too complex, I have a data access layer in. NET that simply configures the connection string in the specified configuration file to invoke Dbhelper.execute (SQL), Dbhelper.executedataset (SQL), dbhelper.executedatatable (SQL), very simple to use, of course, there are entity mappings, Dbhelper.save (entity), Dbhelper.delete (entity or key), Dbhelper.select (conditional) This set of methods can manipulate entity objects, and select returns the list of entities whose associated tables and fields are set through the meta attribute, in which there is no other configuration file except the connection string. In contrast, hibernate needs so many configuration files? I know that hibernate can also be configured with annotations, and there is no need for HBM profiles, but even so, as far as I know, it still requires a lot of other related profiles besides the connection string.
5. Say Java also has so many years, Hibernate also has so many years, in the end is I do not use, or it really is such, hibernate for stored process support, really let me crazy, incredibly do not support stored procedures, To find hibernate call stored procedures on the Internet, the answer is mostly over hibernate, and just get a connection from hibernate, and then call the stored procedure using JDBC, there is a problem, the transaction can not be controlled, Since I'm still comparing the water, Hibernate's transaction control is a black-box operation, as long as the business code written in the service layer is in one transaction, so I can't get my stored procedure calls and Hibernate business code to string in one transaction, and in many cases I'm trying to make them all fail on one failure.
In addition, there is no way to call stored procedures over hibernate, there are two, but also to write the configuration file, one must have a return result set, I am very puzzled, why must have the result set, my many stored procedures just processing some data, It is not necessary to return a result set, and the most uncomfortable is that Oracle's stored procedures do not actually support the return of the result set, and must be returned using a perverted cursor, which I feel is extremely queasy. Another way to do this is by modifying the default behavior of the entity at Insert\update\delete, such as when I insert an employee, it should be an Execute SQL statement insert into employee values (?,?,?,?) , I can modify this default behavior through the configuration file, change to {call MyProc (?,?,?,?)}, this way is obviously not I want, I just want to invoke a stored procedure, perform a business processing. The above two ways will be managed by a black-out office, but not to meet my needs, what should I do?
6. Data access result set objects resultset, RowSet, cachedrowset, etc. are not widely used, and frameworks are more inclined to support the list of entities, which leads to the problem that I can only return the result set of a known structure, If you want to return something temporarily you must also add the corresponding attribute in the entity getxx (); Setxx (); methods, such as Hibernate, to access the employee table, the employee table would have only a department ID, no department name, you want to have a department name, You must add a Deptname attribute to the employee entity, so that all results are known structures, which is painful and can be returned to arraylist<object[]> if not returned to the entity list, but such data does not have a column name. Do not understand why not directly query to resultset, and then let more frameworks support resultset, such as struts, when writing a page using the struts tag, you can manipulate the ResultSet as the entity list.
<s:iterator id= "Myresultset" >...</S:ITERATOR> (or was it originally supported, but I'm not?) That's embarrassing! Just want to let more frameworks support the result set of unknown structure, it is tiring for programmers to design the structure of result set beforehand, even if the code is generated, it can only generate the entity of each table in the database, but often we need select Unkownschema from MyTable Gets the result set of an unknown structure, not every time a select *.
7. Again resultset, the reason is not directly with this, and the use of the entity list instead, I think is also indirectly explained, ResultSet this class is not easy to use,. NET DataSet and DataTable are widely used, because they are easy to use and practical. Perhaps the biggest difference is that the dataset is a disconnected, in-memory micro-database, and resultset is just a connected database reader. The equivalent of DataReader in. NET, must remain connected to read data, I know there is cachedrowset can be disconnected storage data in memory, OK, this is not a problem. But another problem is disturbing me, as a container to store the result set, to give us a way to manipulate the result set is too little, or even to get the result set of the total number of methods, we need to start a small brain, so write: Rs.last (); int count = Rs.getrow (); Rs.first (), it requires at least three lines of code to fetch the total number of rows. Perhaps this is only a small problem, this may be by the brave, industrious, intelligent us to achieve.
8. In my opinion, the big point of struts is that it allows each JSP page to have a corresponding Java class method, that is, the action method. You're going to tell me that struts is not just the way it is, but I say that I've seen a lot of (small companies) projects, and the meaning of struts is just that, I imagine that in our country, there are thousands of companies using Java technology, struts for their meaning, That is, the JSP has a background code. If this is just the case, why not provide the JDK with support from the official, so that struts is advanced to make up for the JDK lag? will only shattered glass.
Or you can say that even if struts is providing a corresponding action method for each JSP page, it's great to do that, and it has completely changed the way people develop web projects by blending the original business code and pages into a decoupled, very successful. I want to say, do not take the glory of your ten years ago to today again, already out of the dead.
9. Again MyEclipse, the IDE is almost standard in the Java system, all the Java developers I have seen are using this IDE, but in contrast, it is too different from Visual Studio, performance is not said, if not optimized, it is slow to die, So why not publish the default settings in one of the most optimized? Wouldn't it be clearer if we needed any plug-in components to load ourselves?
In addition MyEclipse plug-in installation method really let me ashamed, 6.x,7.x,8.x these several versions of Plug-in installation methods are different, I wonder, why can't directly double-click the installation? Vss2005 is the direct double-click installation. So far I have not figured out how to install the SVN plugin, OK, I am very water, that plug-in installation sometimes to copy files to the specified directory, sometimes to start myeclipse, choose the Help menu software updates, and sometimes choose what myeclipse Configuration Center, sometimes to connect the Internet online operation, much more, to give you a Java file, you need to compile a class file, and then follow the steps, I was served.
10.out output parameters, partial classes, extension methods, Lamuda expressions These are very good things, not Java, or am I not? Look at it.
Spring, I don't know what it's for now, okay, it's my sin.
Hope to launch a fierce, hot discussion, you can use the Chamber Kang ceremony, Pentangeli, ten ambush, singled out, and other means of beating.
Java 10 Deadly Sins