Struts + Hibernate Alternative: Struts + Newxy, development efficiency is ten times

xiaoxiao2021-04-02  216

In Java's web development, it is more troublesome by database manipulation. If tools can be efficient like Delphi development database, it will be welcomed by developers.

After five comparisons, Newxy Struts Web development compared to DeiPhi desktop development, the speed is faster and more capable. Http://blog.9cbs.net/nlhlx/archive/2006/06/12/791047.aspx

Newxy is an alternative to Hibernate, Struts Newxy is an alternative to Struts Hibernate.

The shortcoming of Struts is representative of an article: "The huge troubles of Struts is really not suitable for large systems? "Http://dev.9cbs.net/develop/article/85/85114.shtm. The main point of view is: First, when transferred to the display layer, you need to configure Forward, transfer to the display layer every time, I believe that most of them go directly to JSP, involving steering, need to configure Forward, if there are ten display layers JSP It is necessary to configure Ten Struts, and it is not included with the directory, file changes, and needs to re-modify the Forward. Note that after each modification, request to re-deploy the entire project, and the server like TOMCATE, must restart the server, if The business changes complicated frequent systems, such operations are simple and unimaginable. This is like this, dozens of hundreds of people use our system online, everyone can imagine, how big is my troubles. Second, when the page form needs to change automatically or frequently. For a mature MIS system, the page form is definitely unfair, even some systems, the page form is in the database, and the form that needs to be filled in is automatically generated in the page, such as filling out the basic information of a person, or only need to fill in the name. , Gender, date of birth, three indicators, and I will need to increase your origin, I only need to add this record in the database, and automatically increase the origin of the origin to the page. In this regard, Struts has become insufficient, and I have a lot of human resource management systems that almost all can control personnel information inside, and the display layer can be flexible. If Struts is used, these flexibility is not used. Meanwhile The shortcomings of Hibernate, the following is a view of a netizen, representative: 1. Mapping of objects and databases, the key is the mapping of the object relationship, but it has not been ideal, excessive configuration, complicated, and more errors. In fact, the essence is that the object is not free enough. Second, transaction processing. This is more prone to problems, compatible with a wide variety of transaction managers, and there is a lot of problems in a variety of application servers. Its essence is to create a self-data access to a small environment, which must face various compatible issues. Third, HQL language. Establish an object query language, class SQL, but different from any SQL, the debug environment is complicated. The essence is to create a language and increase learning costs. This netizen also put forward disintegration and degradation scheme.

Struts Newxy is more than ten times, or even twice the development efficiency, because of the shortcomings of Struts and Hiberate. With the newxy DAO class, label, struts newxy can write Java code without writing Java code without configuring Struts. Http://blog.9cbs.net/nlhlx/archive/2006/06/11/788541.aspx1. Database increase, delete, change; 2. Specify the data cache to query, specify the cache time; 3. Database character encoding Local character encoding; 4. File upload, upload size control; 5. File download, download count; 6. Picture display; 7. Data page display; 8. Which record of client tag record set is selected;

Because you do not write Java code, you don't have to build an actionform class, the Action class, so you don't have to configure Struts, you don't have to re-package, you don't have to restart the server. You can overcome the shortcomings of Struts. In terms of overcoming the shortcomings of Hibernate, Newxy uses "degradation" and "evolution". Newxy is called, increasing, deleting, and then calls a registration method. According to the database-related data source name and table name, the purpose of the registration is to get the Java class name, the main key to the table field. Data such as field name, primary key field length, saved in a single sub-instance for DAO class calls. If registered is no longer registered. You can register multiple table query statements, such as "SELECT A.FIELD1 AS A, TABLE2 AS B WHERE ..."; you can register with the query of the data source. Such as: "Select A.field1, B.field2 from table1 as a, db3.dto.table2 as b where ..."; if it is data increase, delete, change, is a single table registration; due to struts newxy Instant registration methods, you can image the database to the value object class with a static file like it is like Hibernate. Developers do not need to configure any files. You can use any query statement to overcome the problem of "the object is not free". Hibernate has a sense of meaning between the configuration file settings, and Newxy is "degraded" in this regard, but Struts Newxy is easy to process the relationship between database tables. In terms of transaction processing, Newxy provides a transaction class Net.newxy.dbm.transaction. It can put multiple database operations in a transaction. Since the DAO classes are directly related to the table and its fields of the registration method before the data operation, it is directly related to the database, not the statically file image, and thus a minor error; the developer can pass the transaction method as different Database settings different isolation levels; you can set up a time-back time. If the transaction is not completed during the setting, there will be a thread to intervene, and the transaction rolls back. Hibernate's HQL language is adapted to the database with the object image rule, which does not have a special feature, mainly using the value object class to query the data. Newxy also provides a query language NQL. Developers do not need to build query statements with special syntax. Very easy to understand, do not increase the cost of learning.

Struts is as simple as the combination with Newxy is used together, the following is an example of struts newxy instead of Struts Hibernate.

In the Struts configuration, the FORMBEAN's TYPE is "net.newxy.struts_faces.dynaformbean", and developers do not need to design the Actionform class. Such as:

After the user is data from the page form submit data, in the Action class method, developers can replace Struts Actionform with DynaFormBean, replace the Hibernate object class with Dynadto. public ActionForward methodName (ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {...... DynaFormBean form = (DynaFormBean) actionForm; DynaDto dto = (DynaDto) form.getDto (); dto.set_table ( " Table1 "); // If the user page does not pass the database table name. Try {ifacade ifacade = ifacadefactory.getFacade (HttpServletRequest.getParameter ("_ DAO"), httpservletRequest.getLocale ()); // Most of the situation is: ifacade ifacade = ifacadefactory.getFacade ();

// Update or insert, if result == null, for Update, otherwise INSERT. Result = ifacade.Update (DTO); // or: FormBeanUtils.Update (ifacade, form);

// Remove IFACADE.REMOVE (DTO); // or: formBeanUtils.Remove (ifacade, form);

// Data query, if it is uploaded with data that meets the NEWXY multiple query rules. Query records are placed in the NewForm's _coll property. DynaFormBean newform = new DynaFormBean (); formanutils.createform (newform, httpservletRequest); ... // Developer If you want to know the generated SQL statement, you can: // String SQL = form.get_sql (); / / Since the developer does not need to know the SQL statement while operating the data, there is no way to provide the developer directly get the SQL statement to control the data operation. // Future version may provide such a method. } Catch (Exception E) {...}} If the Action class is not established using the NEWXY tab, the struts of FORMBEAN and ACTION can be used. Newxy technology website: http://www.newxy.net

转载请注明原文地址:https://www.9cbs.com/read-131383.html

New Post(0)