×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Not exactly like you stated

1) I still don't know what you mean by the model and why you compare model with pattern.

2. The reverse of your statement is correct. Using SessionBean to access database is more efficient because one is away from the EJB container overhead in managing persistence. Here is an iron-like rule: If the business concept has no records in the database, you cannot use EntityBean and have to use SessionBean. If you use Container-managed EntityBean, you don't need write much code. However, EJB compiler will generate all the code for you to map the bean variables to database fields. This is code is usually not as efficient as what you write.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / Dear Jabber, I have two questions. Please come in
    First:
    What is the difference of Model and Pattern?

    Second:
    In which condition, we must use Entity Bean instead of Session Bean.

    Thank you very much.
    • Let me try...
      本文发表在 rolia.net 枫下论坛1) The model has very general meanings. We may talk about the business model of a company. However, in the software development, patterns have very specific meaning. A pattern means a general solution that repeat in the different business contexts. For instance, the immutable pattern implies that once some objects are created, we cannnot modify their contents. You can see the immutable pattern in the String class and 8 wrapper classes. You cannot create an Integer as follows:

      Integer i = new Integer(100);

      and change its contents later by re-setting its encapsulated int value. No way! Remind: this unchangeabiliy exists in String, Integer, Boolean, ... but all these things are different. --So they share a pattern---immutable pattern.

      2) EntityBeans are proxies of data in persistence( database). If you are not establishing the proxy in the EJB container for the data stored in the database, you are probably model the client activity and need use SessionBean. Generally, SessionBeans use EntityBeans. Sometimes, you may use your SessionBeans to access database directly and try to avoid use EntityBeans, say, for performance's sake.更多精彩文章及讨论,请光临枫下论坛 rolia.net
      • Thanks. Come in again please
        I think I get some from your post.

        1. the content of Model is much more than that of pattern.

        2. We can always use Session Bean in stead of Entity Bean. But sometimes, Session Beans is less efficient than Entity Bean.

        Am I right? Thanks
        • Not exactly like you stated
          1) I still don't know what you mean by the model and why you compare model with pattern.

          2. The reverse of your statement is correct. Using SessionBean to access database is more efficient because one is away from the EJB container overhead in managing persistence. Here is an iron-like rule: If the business concept has no records in the database, you cannot use EntityBean and have to use SessionBean. If you use Container-managed EntityBean, you don't need write much code. However, EJB compiler will generate all the code for you to map the bean variables to database fields. This is code is usually not as efficient as what you write.
          • Dear Jabber, If the business concept has record in the database, we can use both session bean and entity bean. right?
            So, the advantage of entity bean is that we can write less code. But it is less efficient than session bean. If we choose bean managed persistence, we still need to write database access code. in this condition, which one is more efficient, session bean or BMP entity bean?

            Thank you.
            • If something persist in the database, we use EntityBean to model it. Either CMP or BMP. This is a rule of thumb.
              By the way, I thought about your question again. I just try to say that a simple word can have different meanings in different context.

              We know some patterns. MVC is a big pattern. Since it is a big one, it is also called Model 2, or MVC framework. In addition, MVC stands for Model-View-Controller and here Model means business process in the whole framework. You see, "model" has different meanings.