Reposted: Best J2EE Solution Or Mapping: Hibernate VS CMP, please discuss kuaizxl http://www.jdon.com Apr 1, 2003 9:52 AM Reply or mappingj2ee's standard is CMP Entity Bean, and actual application It is also its most illness. We have been investigating the development method of CMP2.0 for half a year, and the current amount can be reduced to 70%, and it is hoped to reduce 90%. I have been very satisfied with existing results, but when I really read Hibernate, the confidence of CMP2.0 was completely shaken. Hibernate has the following advantages over CMP2.0: 1. Compatibility. The norm is exactly the same, and it is different, which is the status quo of CMP. Use third-party O-R mapping tools to solve this problem. 2. Protect intellectual investment. After understanding Orion, WebLogic, JBoss's CMP implementation, I don't want to learn WebSphere or resin. 3. Performance. a. Local VS Remote, Hibernate, JDO, CASTOR is local call, although there is also a local interface, but the web layer still needs to access the EJB layer data, serialization, network call, create a large number of objects through the Remote interface. It is why performance reduction. b. Transaction, J2EE puts forward a new transaction model (Method-based Descriptor), which is really a "simplified" development of programmers, remembering a tutorial recommended that all EJB methods are used with Required. But what is the result? Performance is extremely low! Interlock! There is no way, we only adjust the Transaction properties of each method, and then new interlocks ... new transaction model is unsuccessful. It tries to simplify the problem, but it introduces a more serious problem. The transaction implementation of each manufacturer is not the same, and some support Optimistic Lock, some in the VM synchronous Entity object, and a big enemy of compatibility. Hibernate did not try to create an updated mode. On the contrary, it took the transaction programming mode of the traditional database. After seeing it after the transaction of J2EE, it is very kind, I feel very kind, I feel that I am programs, not to fill the code . 4. Dynamic query. Entity Bean is difficult to implement dynamic query because it is based on code automatic generation technology, that is, the final execution code is generated during deployment compile. Hibernate has an fundamental change, it is based on the reflection mechanism, and the dynamic query is very natural. In addition, Hibernate supports all SQL syntax, which can be done by traditional databases. 5. Development speed. I have a DREAM, one day entity bean will become very good. But at least, Entity Bean is an imperfect product. It is a large company's political struggle and a compromise product, and habitually puts some questions "indefinite shelves", typical example is Query (not mention other issues) It is because others are the fattest injuries of Entity Bean :)) Form a strong contrast, Hibernate's core programmers have only one person, but it improves the speed of Entity Bean. 6. Inherit and polymorphism. The essence of OO language is in Entity Bean. I have a self-comfort to see the Entity Bean to make a "data sheet in memory", I found a little balance.
But when I saw Hibernate, I was not balanced. In addition, some of CMP2.0 also have some disadvantages that can be compensated. 1. Code maintenance. A large number of interface documents and profiles, development and maintenance work are great. Solution: Use XDoclet, you can automatically produce many interfaces and configuration files, even advanced modes such as Facade, Delegate. At least, Hibernate's shortcomings are: 1. Code Maintenance Hibernate provides a tool that automatically generates the mapping file "Frame", but also needs manual adjustment. And this kind of development, the best mode that can be thought of is the mode of XDoclet (code comment). Fortunately, Hibernate's programmers have added Hibernate modules to the XDoclet project. It is now required to wait for the next release of xdoclet. Conclusion: Hibernate bends at least from the document, there are many Entity Beans, I want to learn Hibernate. Home: Hibernate.SourceForge.net is willing to study Hibernate's multi-exchange communication. Gutyguty2001@sina.comre: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss the presentation time: APR 1, 2003 2:52 PM
Reply Poster: Banq Post article: 3373 / Self: Shanghai / Registration time: 2002-08 For CMP I can only say: Nothing, only right. In fact, your problem is mainly to handle Transaction. If you use JTA, you will still hurt your brains, because this is an application problem, you have to analyze your business objects carefully, which process is a must-have business, usually in the product 1.0 will be removed Transaction, so many smooth, and so on relatively stable mature, then consider Transaction. Imagine Entity Bean into a data sheet in memory, which is in line with the Entity Bean principle, do not hold too much pressure on the Entity Bean CMP, for complex SQL, BMP is a good choice, there is a kind of CMP-BMP Mode: First use BMP, wait for QL after QL, you can return to CMP again, recommend you. Also, in fact, half of the database operation is query, a large number of queries suggest you use DAO mode.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss the presentation time: APR 1, 2003 2:53 PM
Reply Poster: Banq Post article: 3373 / Self: Shanghai / Registration time: 2002-08 I mainly want to say: choose the framework software is best mainstream, Hibernate may be good, but how long is the vitality? If the main developers stop, your products are falling into the development of pause.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: APR 1, 2003 3:03 PM
Reply Poster: WYS1978 Post article: 163 / Registration time: 2002-09 I think JDO will be a better O / R mapping specification, feeling it will become the trend after :)
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: APR 1, 2003 4:08 PM
Reply to: Banq Post article: 3373 / From: Shanghai / Registration time: 2002-08 I think, JDO's biggest shortcoming is that performance optimization is difficult, in fact, this is also an EJB problem, this problem does not resolve, JDO is only available If you are convenient, you want to truly replace the entity bean. I used to use CASTOR, this thing is well used, it is very convenient, but when I use, I don't know how many spaces are still less, I have repeatedly deleted it, I have written it several times, I finally happen. Pooled, and finally I don't know where the problem is, let people die. When opening CMP, because there is almost no problem with JBuilder, it seems that the more automated things, the more important supported development tools. Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: Jul 26, 2003 11:47 AM
Reply to the publisher: newjoy Post article: 9 / Registration time: 2003-06 Good
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 29, 2003 3:01 AM
Reply Poster: Guty Published Articles: 55 / Registration time: 2003-06 All points to Hibernate friends, you are good. This is the article I sent in ChinaJavaworld last year. At that time, a J2EE project was about to end. At that time, I was especially trying to find an EJB alternative technology, I found Hibernate, and later found Rickard's AOP framework. After a few months of testing and basic development, from this beginning, I began to comprehensively adopt a more flexible technology in the project, including Hibernate to make OR, using WebWork / OGNL to do the data binding of web pages, with C And WebServices instead of the Java client. At present, Hibernate is the most correct choice, and the past EJB development (even with xDoclet), everyone feels more than a lot of work. Simple and powerful, can be used to describe many products, or you can describe hibernate. The HQL language can do most of the SQL work, including advanced features such as Outer Join. From the design, Hibernate is supported by the collection, inheriting, so that we can build a sufficient "complex" object model, and can "complete" override the database layer, which is a place that is stronger than EJB. The open source project did exist in Banq's instability, but Hibernate seems to be different. It and Eclipse are the open source project I have seen to truly Small Iteration. The latter has an IBM to make a backing, the former is mainly in almost full-time job in Gavin. At present, Hibernate is version 2.0.1, which can be said to be a very very very stable product.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Published: APR 2, 2003 2:32 PM
Reply Posted by: fishandfly Post article: 44 / Registration time: 2003-03 Castor I have used! In addition to Update is more cumbersome, others can, but their website seems to have a backup server, so there is no new version. I think Castor's transaction is general, and there is no different from ordinary JDBC. I felt that CMP was very good. I watched a lot of articles! It is better to see the OFBIZ's Entity Engine! And OFBIZ also provides data maintenance tools, very good! :) RE: Post: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: APR 2, 2003 3:51 PM
Reply Poster: kuaizXL Post article: 5 / Registration time: 2003-04 As a architect, take more time to pay more attention to the latest technology and development trends, and as a technical person in charge, you should find the best solution. I prefer the latter
RE: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: APR 3, 2003 3:29 PM
Reply Posted by: Jackyz Posts: 35 / Registration time: 2002-11 Great! I am preparing a project, the performance requirements are very high. The last project uses CMP O-R mapping solutions, and its performance cannot be satisfactory. For now, I have the same feeling from the documentation and sample program. Second, in terms of EJB, the way BO Session Facade CMP can be replaced with the implementation of the EJB end with BO session Facade BMP DAO (Hibernate) in Hibernate documents). Alternatively, in the case where the performance requirements are very high, the EJB layer can be removed, simplified to BO (DAO) hibernate. It can be considered that as long as the reasonable design DAO interface, the specific implementation of BO can retain changes in implementation. My project preliminary plan uses MAVERICK Hibernate JCS, give some comments?
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: APR 7, 2003 2:27 AM
Reply Poster: JPENGUIN Published Articles: 16 / Registration time: 2003-04 i studied the sql statements Issued by Hibernate by Turning On SQL Logging of PostgreSQL. At session.flush () and the commission () TIME Hibernate will examine all persistent objects that have been changed (by comparing the new values with old values stored in a cache) in the session and issue SQL update statements for them. There's also XDoclet support for Hibernate now, so if you use that, you Can Switch to CMP if you want.re: Repost: Best J2EE Solutions Or Mapping: Hibernate VS CMP, please discuss Posted: Jun 15, 2003 2:12 AM
Reply to: DREAMASTER Post article: 11 / Registration time: 2003-04 Hibernate Just implement a persistent layer frame should be implemented, so performance is excellent, very strange, why don't you do like CMP? What?
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: Jun 19, 2003 11:14 PM
Reply Poster: Newroc Post article: 3 / Registration time: 2003-06 Recently I recently pay attention to Hibernate, I don't know how much he uses, from the online information about his information is not particularly much, it is not to find or He is more than a new one?
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 20, 2003 9:49 AM
Reply Poster: UU_SNOW Published Articles: 53 / Registration time: 2002-11 If you use hibernate, if I should handle the two DB's CUD operations and an LDAP operation, it seems that the integrity of the transaction cannot be guaranteed Further, can Hibernate handle complex query operations above three tables?
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 21, 2003 10:52 AM
Reply Poster: SuperMY Post article: 24 / Registration time: 2002-10 I have always thought that I have understood EJB, but the more deeper learning, I found that there is still no real understanding. I suggest you learn in-depth, EJB is not as you understand. I think EJB can use the development of the software to the development of industrialization and scale.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 29, 2003 3:32 AM
Reply Poster: Guty Post article: 55 / Registration time: 2003-06 Maybe my understanding of EJB is not very deep, not very clear about some rapid development tools, but according to several experience in the past, I am very clear What work is that EJB is not done, what work is difficult to encapsulate in pure component model. Soon, a friend said that using JBuilder developed EJB very simple, you can do it. I see him so fattle, there is no good face to be cold, but here, you can do the "point-click mouse" to complete: 1. Object Reconstruction, if you want to change the attribute, method, object relationship, maybe the interface is not so Easy; 2. Version control, which files saved on CVS 3. Local debug 4, there is a little, if the object reaches dozens, even hundreds of thousands, if you think that EJB is very easy, I am really very I admire you. Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 30, 2003 11:54 AM
Reply Poster: Banq Post article: 3373 / From: Shanghai / Registration time: 2002-08 to guty: Thank you very much for providing us with Hibernate very good practices, I also like o / r maping, he uses It's really cool. But some doubts let me choose Hibernate immediately, of course, it is its stability and performance, of course, not to negate hibernate, and this is the consistent way of my new technology. Under the mature situation, I will play Hibernate because I have used Castor a year ago, I like it very much. Now Castor handles XML has become a tool box to deal with Object -> XML conversion in my toolbox, and it is implemented in front time JMS Mail, transfers Mail to XML Message, is really fluent. I now use the database persistence tool for EJB CMP. Why do you choose this, you can answer a few questions from GuTy:> 1. Object Reconstruction, if you want to change the properties, methods, object relationships, maybe the interface is not so easy. Because in EJB, the first is to establish Domain Model, entity bean or data model or data table structure is only the implementation of the Domain model. If you change a basic object, such as Customer, you should work two parts: interface design changes; the remaining is achieved, there are two types: data model changes; database structure changes. The above changes should be done by what technologies taken such as O / R mapping. In EJB, after the database structure changes, through JBuilder's database import technology, the changed data table can be immediately mapped into entity beans, which is done by the container. In other words, after the database structure changes, the actual entity bean changes, so the EJB entity bean does not bring us additional work. 2. Version control problem Because JBuilder integrates mainstream tools such as CVS, it is also very convenient to pass WinCVS. 3. Local debugging, the JUnit or CACTUS navigation settings of JBuilder integrates, is very convenient. 4. After hundreds of objects, you need a clear web and ejb control framework to encapsulate these hundreds of objects. The serial number of EJB components, this can refer to PetStore, and PetStore actually uses a lot of EJB components, and the real code is very small. Here I want to say more, EJB distributed components are powerful advantages, programmers can divide into components debug coding, which is convenient, when issued together, due to the automatic cluster function of the container, released to a server It will automatically run on hundreds of cluster servers, automatically realize dynamic load balancing, as well as single-point error recovery, which has been done. These ripe frames have been using EJBs. Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Time: Jun 30, 2003 1:30 PM
Reply Poster: Robbin Post article: 585 / Registration time: 2003-06 CMP is really very convenient in JBuilder, but only 1 table is mapped in JBuilder, if the table is very large, and many tables Is there an association? I have encountered more than 80 tables in the database. Most of them use the connection query. If it is mapped with CMP map, these all the relationships must be designed as CMR, that means that These more than 80 CMPs must be designed in an EJB Deginer and can only be made into a JAR package. This is a very horrible thing, slightly wrong, all over the veteran. If it is BMP, you can write a connection in SQL, if it is hibernate, the same. However, CMP can not do it, only CMR can only be used in a JAR package, there is no way to CMR, so more than 80 CMPs are in a package how terrible, and the three configuration files are almost a few thousand lines. The maintenance is too fragile. Even in jbuilder, it is not moving. Later, the project didn't fail! Now CMP will not directly expose to the client, encapsulate the entity bean with session bean, then the CMP transaction function, the security check is not necessary, the light is a function of o / r mapping, it is not necessarily CMP. Distributed can be implemented using Session Bean JDO (O / R mapping). More accurately, even business objects can be distributed in front of the Session Facade in front. Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss the Published: Jun 30, 2003 1:43 PM
Reply Poster: Guty Post article: 55 / Registration time: 2003-06> A session facade can be distributed in front of the SESSION FACADE. Very much agree. Do it down, you will find that EJB is getting more and more cumbersome. Is RMI difficult to achieve? Is JNDI really necessary? Is Cluster necessary to do so complicated? Then you may be a "server" yourself.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Posted: Jun 30, 2003 1:48 PM
Reply Poster: Guty Post article: 55 / Registration time: 2003-06> Do then do it, you will find that EJB is getting more and more cumbersome. Is RMI difficult to achieve? Is JNDI really necessary? Is Cluster necessary to do so complicated? > Then you may be a "server" yourself. This is still the case of the Java application client. If it is a web program, or the client is other language, even RMI does not have the need, Cluster and session mechanisms can use Web Server, which is a more stable and mature solution.
Re: Reposted: Best J2EE Solutions O-R Mapping: Hibernate V.S. CMP, please discuss Published: Jun 30, 2003 3:17 PM
Reply Poster: Robbin Post article: 585 / Registration time: 2003-06 Guty, Hello, continue to discuss Hibernat's transaction, use ThreadLocal to save session and transfer: Save Transaction in Threadlocal, you did not care when Transaction Create, when is submitted, I understand that after creating sessions, immediately create Transaction, the web layer is completed, submit transaction, shut down the session. This way, you can write a Filter to deal with the submission transaction and close the session. Manage Session and Thread, manage Session and Thread, and independently. But doing this question: If the business method is just querying the database, there is no modification operation, then it is necessary to start Transaction? In the above management method, when the Web layer is called to DAO, it will launch session and transaction, and finally submit transaction and close session. If you just query the database, if you don't modify it, it is not necessary to start Transaction. HibernateSession.CurrentSession () method is impossible to distinguish the call back is read-only, still have modifications, always starting a transaction, and always submit transaction in Filter. Then I care about the question, although hibernate's Transaction is a JDBC Transaction, it will not cause a large system overhead, but the database read-only query is commit, how much is this overhead? Will it seriously affect performance? I made a simple trial, query my mysql database with Hibernate, and query 500 databases, do statistics. Since it is only querying the data, it is not necessary to use Transaction. After comparison, after using Transaction, the average query time is 600ms, which means that the average time overhead of each query is more than 1 ms. On my AMD DURON700 machine, the CPU usage of the MySQL database rose from 19% to 24%. In a real environment, there will be no threads that have repeatedly query the database, so more 1ms of time overhead can be completely ignored. But the overhead of the database is still very considerable, and if it is concurrent thread access, I believe that the overhead of the database will increase. So I think I can improve your program, and Filter does not have to change it, and TX is not submitted for the air. HibernanceSession.currentSession () can send it a parameter, such as Query data, when you do not modify the database, give it 0, light creation session or take the session, not to start Transaction, not 0 when it is not 0 TRANSAction . Overall, it is quite easy to use this approach. > If it is a web program, or the client is other language, even RMI does not have to use Web Server, which is a more stable and mature scheme if Web Server and App Server are not in a physical machine. What about? You still have to use Session Bean.