60 Second Delays in Client Getting Entity Bean (after finder method)

I am running WLS5.1 with SP10. I have a stateless EJB that gets a
read-write BMP entity EJB. My test client that executes the stateless
session bean periodically encounters long delays (60 seconds or more)
when acquiring the entity bean using its finder method. Logging shows
the finder method is executing properly, and typically takes 180 ms to
locate the entity bean; however, from the stateless session beans side,
it appears to take 60 seconds. The test client is only a single thread,
so I know the pool is not depleted, or anything like that. Something
appears to be going haywire with the container.
Does anybody have an idea what might be going on?
Thanks.
Greg

Hi Greg,
On a whim, I tried the same test with the thin driver, and the same
delay occurred. This time, instead of a rollback being at the top ofthe
thread dump stack trace, it was in some other Oracle call, with the
top of the stack trace being a socketreader.are you using MTS? Is the db-server a SMP-box? Which exact patch level
does your Oracle instance have? If yes, can you try to force a dedicated
server connection and see if the problem disappears? I guess for an OCI
connection you will have to edit tnsnames.ora, for a
thin-driver-connection you would have to modify the connect string to
something like this:
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOS
T=<dnsname>)(PORT=1521)))(CONNECT_DATA=(SID=<your
sid>)(SERVER=DEDICATED))))
There is a bug in 8.1.6.0 which is supposed to be fixed in 8.1.6.3, but
I can still reproduce it in 9i :-(. It makes the MTS-dispatcher hang for
60 seconds if you have an SMP box with low load, so maybe this could be
your problem.
Daniel
-----Original Message-----
From: Greg Crider [mailto:[email protected]]
Posted At: Wednesday, November 28, 2001 8:17 AM
Posted To: ejb
Conversation: 60 Second Delays in Client Getting Entity Bean (after
finder method)
Subject: Re: 60 Second Delays in Client Getting Entity Bean (after
finder method)
My client has been using OCI in production and development
with JTS for
over a year now without a problem. We went to OCI because
there was some
other problem with the thin driver. I'm not sure what the
problem was,
but Oracle acknowledged it, but said it wouldn't be corrected until
Oracle 9i came out. We're still using 8.1.6, so from what I'm
told, we
don't use the thin driver.
On a whim, I tried the same test with the thin driver, and the same
delay occurred. This time, instead of a rollback being at the
top of the
thread dump stack trace, it was in some other Oracle call, with the
top of the stack trace being a socketreader.
Somebody else suggested that there may be a problem with
transactions.
Does this ring a bell? Again, I have a stateless session bean
invoking a
read-write entity bean, invoking a read-only entity bean. From
everything I read, including weblogic docs, I should just rely on my
deployment descriptor to control transactions and stay away from JTA.
Hi Greg,
I remeber long ago there were an issue with jts/oci driver combination
when the connections were opened but never used...
Buy the way, are there any specific reasons to use OCI instead of
thin driver?
"Greg Crider" <[email protected]> wrote in message
news:[email protected]...
I know. That's what I don't get. BTW Slava, I am using the
latest OCI
driver; thanks for the suggestion. I tried tweaking some of the Solaris
kernel settings as relates to TCP, but that didn't clear up the problem
either; however, it did change the frequency. Modifying the retransmit
settings (very small values, sub 1.5 seconds) seemed to make it occur
less frequently.
It seems like its time for me to contact BEA Support and see what they
can turn up. Thanks for the suggestions. If anybody else has an idea,
let me know. I'm betting this is a simple, stupid config problem. I'll
post back here when I find out what's up.
But for some reason WebLogic code called the rollback:
... rollback
at
weblogic.jdbc.common.internal.ConnectionEnv.cleanup(Connection
Env.java:499)
at
weblogic.jdbc.common.internal.ConnectionEnv.destroy(Connection
Env.java:417)
at
weblogic.jdbc.common.internal.ConnectionEnv.destroy(Connection
Env.java:393)
at weblogic.jdbcbase.jts.Connection.close(Connection.java:274)
at weblogic.jdbcbase.jts.Connection.commit(Connection.java:530)
at
weblogic.jdbcbase.jts.TxConnection.commitOnePhase(TxConnection
.java:55)
at
weblogic.jts.internal.CoordinatorImpl.commitSecondPhase(Coordi
natorImpl.java
:484)
at
weblogic.jts.internal.CoordinatorImpl.commit(CoordinatorImpl.java:383)
at weblogic.jts.internal.TxContext.commit(TxContext.java:255)
Slava Imeshev <[email protected]> wrote:
Hi Greg,
Which version of OCI driver do you use? OCI driver proved to be
not that stable as the thin driver. Could you try to download
and to install the latest version of the OCI driver and
let us know
if it helps?
Regards,
Slava Imeshev
[email protected]
"Greg Crider" <[email protected]> wrote in message
news:[email protected]...
Yup, get fresh connection from the db connection pool,
and close it
>when
I'm done. The logs don't indicate that I've ever exhausted the
connection pool.
It's interesting to note these problems are occurring on
Solaris with
Oracle OCI connections. Running the same code under Linux with thin
driver connections works just fine.
Weird. Do you obtain database connection from a
datasource and close
>it
every time
you use it?
Greg Crider <[email protected]> wrote:
Okay, this appears to be the offending thread. As it
turns out, the
>same
behavior as first described in my initial post, is
occurring this
>time
in the
business method of the entity bean, as opposed to the
finder. The
getNextURL() is the business method in this case. I am using BMP, and
the
ejbLoad() and ejbStore() methods are not throwing any
SQLExceptions.
Also, I
don't see anything in the error logs that indicate a
EJB transaction
failure.
This being the case, why would an Oracle rollback be
attempted? Am I
misinterpretting this stack trace?
"ExecuteThread-67" daemon prio=5 tid=0x14e300 nid=0x51 runnable
[0xe7880000..0xe7881a30]
at oracle.jdbc.oci8.OCIDBAccess.do_rollback(Native Method)
at oracle.jdbc.oci8.OCIDBAccess.rollback(OCIDBAccess.java:417)
at
oracle.jdbc.driver.OracleConnection.rollback(OracleConnection.java:510)
at
weblogic.jdbc.common.internal.ConnectionEnv.cleanup(ConnectionEnv.java:4
>99
at
weblogic.jdbc.common.internal.ConnectionEnv.destroy(Conne
ctionEnv.java:4
>17
at
weblogic.jdbc.common.internal.ConnectionEnv.destroy(Conne
ctionEnv.java:3
>93
at weblogic.jdbcbase.jts.Connection.close(Connection.java:274)
at weblogic.jdbcbase.jts.Connection.commit(Connection.java:530)
at
weblogic.jdbcbase.jts.TxConnection.commitOnePhase(TxConnec
tion.java:55)
at
weblogic.jts.internal.CoordinatorImpl.commitSecondPhase(CoordinatorImpl.
>ja
va:484)
at
weblogic.jts.internal.CoordinatorImpl.commit(CoordinatorIm
pl.java:383)
at weblogic.jts.internal.TxContext.commit(TxContext.java:255)
at
weblogic.ejb.internal.StatefulEJBObject.postInvokeOurTx(StatefulEJBObjec
>t.
java:320)
at
weblogic.ejb.internal.BaseEJBObject.postInvoke(BaseEJBObje
ct.java:845)
at
com.pi.speechport.ETO.LoadShare.ETOLoadShareEJBEOImpl.getNextURL(ETOLoad
>Sh
areEJBEOImpl.java:114)
at
com.pi.speechport.ETO.Transcription.ETOTranscriptionBusin
ess.getVendorUR
>L(
ETOTranscriptionBusiness.java:146)
at
com.pi.speechport.ETO.Transcription.ETOTranscriptionBusin
ess.transcribe(
>ET
OTranscriptionBusiness.java:193)
at
com.pi.speechport.ETO.Transcription.ETOTranscriptionEJBEO
Impl.transcribe
>(E
TOTranscriptionEJBEOImpl.java:188)
at
com.pi.speechport.ETO.Transcription.ETOTranscriptionEJBEO
Impl_WLSkel.inv
>ok
e(ETOTranscriptionEJBEOImpl_WLSkel.java:223)
at
weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(B
asicServerObjec
>tA
dapter.java:347)
at
weblogic.rmi.extensions.BasicRequestHandler.handleRequest
(BasicRequestHa
>nd
ler.java:86)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicEx
ecuteRequest.ja
>va
:15)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:129)
Dimitri Rakitine wrote:
Make a thread dump during these 60 seconds to see
what server is
>doing.
Greg Crider <[email protected]> wrote:
I am running WLS5.1 with SP10. I have a stateless
EJB that gets a
read-write BMP entity EJB. My test client that executes the
stateless
session bean periodically encounters long delays (60
seconds or
>more)
when acquiring the entity bean using its finder
method. Logging
>shows
the finder method is executing properly, and
typically takes 180 ms
>to
locate the entity bean; however, from the stateless
session beans
side,
it appears to take 60 seconds. The test client is
only a single
thread,
so I know the pool is not depleted, or anything like that.
Something
appears to be going haywire with the container.
Does anybody have an idea what might be going on?
Thanks.
Greg
Dimitri
Greg
>__
GREGORY K. CRIDER, Emerging Digital Concepts
Systems Integration/Enterprise Solutions/Web &
Telephony Integration
(e-mail) [email protected]
(web) http://www.EmergingDigital.com
(voicemail) 866-474-4147
(phone) 703-335-0974
(cell) 703-851-5073
(fax) 703-365-0223

Similar Messages

  • Problem with getting Entity Beans refreshed within Session bean methods

    I hav following code in session and entity beans:
    Session bean pseudo code: (PrimaryKey is primary key class for the entity
    bean referred here, and MySessionHome is the home interfac class for this
    session bean).
    public class MySession implements SessionBean {
    // This method is present in remote interface class as well.
    public void methodA(PrimaryKey pk) {
    // code to find entity bean by primary key specified.
    update the entity bean, and mark it as isModified.
    public void methodB(PrimaryKey pk) {
    // code to find entity bean by primary key specified.
    do something.
    public void methodC() {
    MySessionHome sessHome = code to lookup sessionhome from JNDI.
    MySessionRI sess = sessHome.create(); // MySessionRI is the remote
    interface class for MySession
    PrimaryKey pk = new PrimaryKey(params);
    sess.methodA(); // LINE ABC1
    sess.methodB(); // LINE ABC2
    all the entity and session bean methods have required as the TX attribute.
    In methodB() on LINE ABC2, the entity bean obtained by findByPrimaryKey does
    not reflect the changes made in call to methodA() on LINE ABC1.
    Now if I change the LINE ABC1 and LINE ABC2 to
    methodA(); // LINE ABC1
    methodB(); // LINE ABC2
    in this case the entity bean obtained in methodB() has the changes made in
    methodA().
    Any idea why this is happening?

    Hi ad13217 and thanks for reply.
    I'm sorry but my code is like this:
    javax.naming.Context ctx=new javax.naming.InitialContext();
    arguments was an error on copy, but it doesn't work.
    Thanks
    Fil

  • How to clear the value of a variable in a managed bean after AM method...

    I have two inputText fields on a page - user inputs a value in FieldA and performs a search (execute w/ params)... FieldB shows up under Results table with an 'Add' button. User can enter a value in FieldB and click 'Add' to insert a new row in the Results table.
    I got the insert to work by making FieldB binding = #{userState.newVisitorId} where userState is a session scoped bean.
    When the page reloads after the insert, the value entered in FieldB is still there - I want to clear it out. I know 'marrying' the AM code for the insert to the View code for the bean is bad practice; what is a better way to do this?
    Thanks!

    For anyone who might also be looking for this solution... I simply added a SetActionListener to the 'Add' button that was set as From: #{null} To: #{userState.newVisitorId} and it works like a charm.

  • Confused with Entity Beans

    Hello:
    I ve been trying to learn EJBs using Wrox's Professional EJB.
    At page number 145 sequence diagram, it shows that ( for a bean
    managed persistance Entity bean ) every find<METHOD>(args) invoked on
    an EJBHome object will be delegated to a corresponding
    ejbFind<METHOD>(args) method on the bean implementation object. I m a
    bit confused here.
    1. Since from the OO point of view, "find" is about finding, shouldn t
    this have been a method on some kind of broker object, that should
    have created/found the corresponding implementation objects and
    returned the corresponding handles ( object references ). In the case
    of findInRange() that returns multiple objects this becomes more
    apparent, wherein one need to have an ejb implementation object to
    start with in order to get the collection of objects he has been
    looking for. Where did I 'didn t get it'
    2. One of my friends says Container managed persistence ( CMP ) is not
    at all popular due to the inefficiency compared to BMP, and that only
    very few projects will be actually using it. Is there any truth in
    this.
    3. Is there a vendor neutral newsgroup ( and more specific that
    comp.java.lang.help ) for posting ejb related discussions.
    Thanks
    --sony

    Hi Sony,
    "Sony Antony" <[email protected]> wrote in message
    news:[email protected]..
    Hello:
    I ve been trying to learn EJBs using Wrox's Professional EJB.
    At page number 145 sequence diagram, it shows that ( for a bean
    managed persistance Entity bean ) every find<METHOD>(args) invoked on
    an EJBHome object will be delegated to a corresponding
    ejbFind<METHOD>(args) method on the bean implementation object. I m a
    bit confused here.
    1. Since from the OO point of view, "find" is about finding, shouldn t
    this have been a method on some kind of broker object, that should
    have created/found the corresponding implementation objects and
    returned the corresponding handles ( object references ). In the case
    of findInRange() that returns multiple objects this becomes more
    apparent, wherein one need to have an ejb implementation object to
    start with in order to get the collection of objects he has been
    looking for. Where did I 'didn t get it'In fact, a bean serves as the "broker" object, though I don't like
    the name that much. Finally, this is the Spec, and you have to
    live with it.
    2. One of my friends says Container managed persistence ( CMP ) is not
    at all popular due to the inefficiency compared to BMP, and that only
    very few projects will be actually using it. Is there any truth in
    this.It depends on application requirements. CMP are perfect for writing
    simple persistance objects with "one object per one DB table" pattern.
    From efficiency point of view weblogic does it's best to optimize
    bean's behaiviour. You shouldn't be concerned about it.
    BMPs are good when you need to deal with coarse-grained persistance.
    I'd recomend you to get hands on experience with CMPs and
    BMPs. Practice is invaluable source of knowlege.
    3. Is there a vendor neutral newsgroup ( and more specific that
    comp.java.lang.help ) for posting ejb related discussions.weblogic.developer.interest.ejb is a perfect place for this type of
    discussions.
    Regards,
    Slava Imeshev

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • Question on Persistence (Entity Beans, Hibernate, JDBC)

    Hi everybody!
    Until now, I have read a lot about persistence in the J2EE-sector, but I am still confused about which technology to used in my case.
    I hope, that maybe you can give me some hints, by telling me which technology is good or bad regarding my requirements:
    I want to build a customer- and order-management system fullfilling the following requirements:
    1. The client is a Java application, the server is a JBOSS 4.0.1
    2. The databasa scheme exists already and I'm not allowed to change it.
    Some data, that logically belongs together and which shall be presented together to the client is distributed over 2 database tables.
    3. The user cannot just create new and view data, but will also edit existing data quite often.
    4. The user can assign products to an order. Often, there will be more than 1000 products assigned to an order, which will be presented to the user as a table (e.g. JTable). The user can then edit each cell of that 1000-row table, which of course will lead to an update in the db.
    5. The user can also assign customers to a specific role in an order-process. On the other hand, each customer can make many orders.
    So, we have a n:m relation here with the db-tables Customer, Order, OrderCustomer.
    6. A complex search functionality has to be implemented, where the db-query is created dynamically at runtime.
    7. The application is a multi-user application (about 10 users). It will be very rare, that users will work on the same data at the same time, but it might happen.
    8. The database type (SAP DB) will not be changed in the near future.
    With these 8 requirements in mind, I dealed a lot with EntityBeans, Hibernate and JDBC with SesseionBeans during the last 2 weeks.
    Until now, I came to the following conclusions.
    Hibernate is too slow. That'S bad, for data is edited very often and sometimes I want to edit just a single cell in 1000-row table.
    Hibernate's biggest advantage - that it makes your application independent of the database type - is not even required (see point 8).
    JDBC with SessioBeans: Very fast (I tried a simple query and it was about 10 times faster than Hibernate).
    The disadvantage is, that I have to take care about all the transaction, concurrency control etc. things.
    If I use JDBC, I want to do it that way: A SessionFacade accesses a DAO-object which executes the DB-query and returns the result to the SessionFacade which in the last step will pass the result to the client.
    Entity Beans: I am completely confused with Entity Beans.
    I read a lot about the CompositeEntity-Pattern for BMP. But on sun's J2EE Pattern page (http://java.sun.com/blueprints/corej2eepatterns/Patterns/CompositeEntity.html)
    they said, that it's just useful when using the EJB 1.1 specification, because from EJB 2.0. the container or whatever will take care about lazy loading and store optimization.
    So, from EJB 2.0. you should prefer using CMP-Beans with Container Managed Relationships (CMR), but as I heard, the dependent objects cannot be accessed and changed by the client when using CMPBeans with CMR.
    However, a simple DB/Entity-mapping will not work in my case, because as mentioned above, there are thousands of products from the db to be managed at the same time. So here, I thought, the Composite pattern with its lazy loading strategy would be useful.
    Furthermore, I have an n:m relationship in my database scheme, which is not trivial to map to entity beans. And don't forget that some related data is spread over 2 databse tables.
    To sum it up, it would be very nice if some of you could clarify this perisistence nightmare, especially some clarification about if and how to use EntityBeans when having n:m relationships, editing data a lot, managing lots of table rows at once and having related data distributed over 2 database tables.
    So, which technology would you prefer with the 8 requirements in mind? Hibernate, Entity Beans or JDBC with SessionBeans? Or would you prefer a mixed solution?
    Thanx for every hint.
    Regards,
    egon

    Here the requested information about the test:
    Goal:
    Find all customers, who's branches have the String "Branch" in their name.
    Both times, a simple client accesses the same SessionBean in a JBOSS-Container.
    This Bean has 2 methods. One accesses the DB via Hibernate (executeCriteria), the other one via JDBC (executeCriteriaJDBC).
    The code to count the seconds of computation is as follows:
    long startTime = System.currentTimeMillis();
    List customerList = bean.executeCriteria(dc);
    System.out.println("Hibernate: "+((System.currentTimeMillis()-startTime)/1000.0f)+" sek");
    startTime = System.currentTimeMillis();
    List customerListJDBC = bean.executeCriteriaJDBC(query);
    System.out.println("JDBC: "+((System.currentTimeMillis()-startTime)/1000.0f)+" sek");
    HIBERNATE:
    CODE:
    Branch Branch = new Branch();
    Branch.setName("%Branch%");
    Example example = Example.create(Branch);     
    DetachedCriteria dc = DetachedCriteria.forClass(Customer.class)
    .createCriteria("branches").add(example.enableLike()).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
    QUERY:
    select
            this_.UUID as UUID1_1_,
            this_.NAME as NAME1_1_,
            this_.CUSTOMERNO as CUSTOMERNO1_1_,
            this_.SHORTDESC as SHORTDESC1_1_,
            this_.LONGDESC as LONGDESC1_1_,
            this_.TAXNUMBER as TAXNUMBER1_1_,
            this_.SALESTAXID as SALESTAXID1_1_,
            this_.ACCOUNTHOLDER as ACCOUNTH8_1_1_,
            this_.BANKACCOUNT as BANKACCO9_1_1_,
            this_.BANKCODE as BANKCODE1_1_,
            this_.BANKNAME as BANKNAME1_1_,
            this_.AREA1TEXT as AREA12_1_1_,
            this_.AREA2TEXT as AREA13_1_1_,
            this_.AREA3TEXT as AREA14_1_1_,
            this_.AREA4TEXT as AREA15_1_1_,
            this_.AREA5TEXT as AREA16_1_1_,
            this_.CH_UUID as CH17_1_1_,
            this_.REFTEXT1 as REFTEXT18_1_1_,
            this_.REFTEXT2 as REFTEXT19_1_1_,
            this_.REFTEXT3 as REFTEXT20_1_1_,
            branch1_.UUID as UUID0_0_,
            branch1_.NAME as NAME0_0_,
            branch1_.ILN as ILN0_0_,
            branch1_.BRANCHID as BRANCHID0_0_,
            branch1_.SHORTDESC as SHORTDESC0_0_,
            branch1_.LONGDESC as LONGDESC0_0_,
            branch1_.BAGSRECEIVED as BAGSRECE7_0_0_,
            branch1_.CUSTOMER_UUID as CUSTOMER8_0_0_
        from
            CUSTOMER this_,
            BRANCH branch1_
        where
            this_.UUID=branch1_.CUSTOMER_UUID
            and (
                branch1_.NAME like ?
    RESULT:
    Customername: Customer_A
    Customername: Customer_F
    Customername: Customer_D
    Customername: Customer_R
    Customername: Customer_S
    TIME:
    Hibernate: 1.343 sek
    JDBC:
    QUERY:
    Select distinct c.* from Customer c, Branch b where b.id=b.Customer_id and b.name like '%Branch%'
    // After getting the result of the query: Create a list of Customer-objects. Set all attributes of each Customer-object.
    RESULT:
    Customername: Customer_R
    Customername: Customer_A
    Customername: Customer_S
    Customername: Customer_D
    Customername: Customer_F
    TIME:
    JDBC: 0.125 sek
    The Customer.hbm.xml (auto-generated in Eclipse with Middlegen)
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
    <hibernate-mapping>
    <!--
        Created by the Middlegen Hibernate plugin 2.2
        http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    -->
    <class
        name="hibernate.hibernate.Customer"
        table="CUSTOMER"
        lazy="false"
    >
        <id
            name="uuid"
            type="java.lang.String"
            column="UUID"
        >
            <generator class="assigned" />
        </id>
        <property
            name="name"
            type="java.lang.String"
            column="NAME"
            length="100"
        />
        <property
            name="customerno"
            type="java.lang.Integer"
            column="CUSTOMERNO"
            length="5"
        />
        <property
            name="shortdesc"
            type="java.lang.String"
            column="SHORTDESC"
            length="50"
        />
        <property
            name="longdesc"
            type="java.lang.String"
            column="LONGDESC"
            length="100"
        />
        <property
            name="taxnumber"
            type="java.lang.String"
            column="TAXNUMBER"
            length="50"
        />
        <property
            name="salestaxid"
            type="java.lang.String"
            column="SALESTAXID"
            length="50"
        />
        <property
            name="accountholder"
            type="java.lang.String"
            column="ACCOUNTHOLDER"
            length="50"
        />
        <property
            name="bankaccount"
            type="java.lang.String"
            column="BANKACCOUNT"
            length="50"
        />
        <property
            name="bankcode"
            type="java.lang.String"
            column="BANKCODE"
            length="50"
        />
        <property
            name="bankname"
            type="java.lang.String"
            column="BANKNAME"
            length="50"
        />
        <property
            name="area1text"
            type="java.lang.String"
            column="AREA1TEXT"
            length="50"
        />
        <property
            name="area2text"
            type="java.lang.String"
            column="AREA2TEXT"
            length="50"
        />
        <property
            name="area3text"
            type="java.lang.String"
            column="AREA3TEXT"
            length="50"
        />
        <property
            name="area4text"
            type="java.lang.String"
            column="AREA4TEXT"
            length="50"
        />
        <property
            name="area5text"
            type="java.lang.String"
            column="AREA5TEXT"
            length="50"
        />
        <property
            name="chUuid"
            type="java.lang.String"
            column="CH_UUID"
            length="50"
        />
        <property
            name="reftext1"
            type="java.lang.String"
            column="REFTEXT1"
            length="50"
        />
        <property
            name="reftext2"
            type="java.lang.String"
            column="REFTEXT2"
            length="50"
        />
        <property
            name="reftext3"
            type="java.lang.String"
            column="REFTEXT3"
            length="50"
        />
        <!-- Associations -->
        <!-- bi-directional one-to-many association to Branch -->
        <set
            name="branches"
            lazy="true"
            inverse="true"
           cascade="all"
        >
            <key>
                <column name="CUSTOMER_UUID" />
            </key>
            <one-to-many
                class="hibernate.hibernate.Branch"
            />
        </set>
    </class>
    </hibernate-mapping>So, seems to me like Hibernate is also getting the data from the Branch-Table related to each Customer. Maybe this is the reason, why Hibernate is slower.
    But as you can see in the mapping-File of the customer, I wanted Branches to be lazy loaded.
    Do you have any ideas, why Hibernate is so much slower? Any hints for optimizing that code?
    Do you have any further tricks to optimize Hibernate? Unfortunately I am not allowed to make changes at the database, so I cannot e.g. set indices for optimization.
    However, I�m a Hibernate-Newbie. In fact, I just made this test and was very disappointed about its result, so I didn�t keep on working with Hibernate.
    But maybe you can proof me, that Hibernate is a good choice. If so, do you have any good resources (links, books) that help working with Hibernate in connection with JBOSS, describe how to map n:m relationships, show how to work with large results and so forth?
    Thanx for help,
    egon

  • Entity beans not understood

    hello,
    I am new to ejb. I know that I have come to the right technology and now to the right forum. I have got quite a good grasp on session beans but I don't understand the entity beans.
    I have a couple of questions.
    Firstly if every bean represents a single record in a database then what's th logic behind having these beans in the first place. suppose I have about 10 milion records in one of my table then does that mean I have 10000000 instences of that entity bean? and what will be the advantage of such an arrangement.
    secondly, do I always need entity beans to manage data from a database? I mean what is wrong if I do all that in a session bean? I do connect to a database with jdbc in servlets and jsp, so what is the problem in doing same in a session bean.
    and one general question, how heavy is the remote object on the client machine, what I am asking is, if when I locate the bean using the home interface or home object if you like it, I get access to the remote object. so how heavy is the remote object when I download it on my client machine?
    thanks
    Krishnakant.

    Hi,
    If you want to have 10 million records it is not necessarily 10 million Entity Beans will be instatiated. EJB container pools the EntityBeans and uses then accordingly.
    Writing DataBase code in Servlets/JSP is not a good idea. If you want to get the benefits of layered Architecture we have to follow certain design patterns. DB operations can be handled trhu EntityBeans are DAO factories.

  • Multiple create methods of entity beans in single transcation

    Hi,
    I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transaction type is Container Managed for all its methods.
    In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creating two entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch block.
    I want that the entire operation be under just one transcation so i have also given the transaction attribute as Required for all methods of Session bean and Entity Beans.
    However if i pass invalid parameters to second create method so that it generates exception then still the first create statement is successful and database is updated.
    what i want is that the first create also should be roll backed.
    How can i acheive this through Container Managed Transaction Session Bean?

    Hi Ashwini,
    "Ashwini" <[email protected]> wrote in message news:400291af$[email protected]..
    I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transactiontype is Container Managed for all its methods.
    >
    In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creatingtwo entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch
    block.
    >
    I want that the entire operation be under just one transcation so i have also given the transaction attribute asRequired for all methods of Session bean and Entity Beans.
    >
    However if i pass invalid parameters to second create method so that it generates exception then still the firstcreate statement is successful and database is updated.
    what i want is that the first create also should be roll backed.
    How can i acheive this through Container Managed Transaction Session Bean?o Do you use TXDatasource with your entity beans?
    o In CMT transactions are automatically rolled back only when RuntimeExceptions
    are thrown. What kind of exception is thrown in your case?
    Regards,
    Slava Imeshev

  • Entity bean (ejb 3.0) refactoring problem

    I didn't find a better method than regenerating an entity bean after modifying the table definition and renaming the class after deleting the old one.
    I'm not sure i can delete the old class representing the entity bean before regenerating it without any effects into the others entity beans.
    It work fine but still a little problem. The refactoring process didn't change the name of the entity bean into the select clauses into queynamed injection.

    I am facing a similar problem. Does JDeveloper 10g (10.1.3.3.0) provide an automatic process to update an Entity Bean definition when the underlying database table definition changes?
    I also noticed that for JDeveloper to create all the relationships (i.e. @OneToMany, @ManyToOne) between multiple Entity beans, I need to create all the Entity beans together in one pass using the wizard. If two entities depend on each other, and not created together, JDeveloper will not create the relationships between them. Is there a way around that?
    Thank you

  • Update beans after adding columns to DB tables

    I am trying to use JDeveloper 10G , Studio Edition Version 10.1.3.0.4.3673
    I am having difficulty finding out how to update CMP Entity Beans
    after adding columns to DB tables.
    I have found descriptions of how to do these from four sources.
    None of these methods work.
    They all refer to menu options, buttons or fields that aren't in the JDevb IDE.
    List of options that don't exist :
    "Synchronize with Database"
    "attributes"
    "Add from table"
    "New from Table"
    "Fields Tab"

    What version of EJBs are you using?
    The only option I know of for EJBs will be to generate the bean from the table again, or manually add the field to the EJB.
    The "Synchronize with Database" operation is there for ADF Business Components but not for EJBs.

  • Wrong version of an entity bean object being updated

    We are having a problem with an entity bean that uses bean managed persistence. The "order" entity bean has
    been used as part of our Order Routing System for the last 2 years with no problems. The entity bean is
    accessed via calls from a "Order Manager" session bean. No change has been done to the entity bean but the
    frequency of calls from the session bean to update the entity bean have increased significantly.
    The "order" entity bean wraps an Order object that contains order properties (i.e. id, quantity, price,
    version, etc). The entity bean has a "void setOrder(Order param)" function that writes the Order to a database
    and a "Order getOrder()" function that clones and returns the internal Order object. The "ejbLoad()" function
    reads the Order object from the database and the "ejbStore()" function is not implemented.
    The "OrderEntityPK ejbFindByPrimaryKey()" function checks if the order entity primary key (an "int") exists
    on the database.
    We are using the SilverStream 3.5 application server as our EJB container. According to the SilverStream manual
    it does not maintain a pool of idle/unused entity beans, instead it instantiates beans as requested.
    Our problem is:
    1) The wrong version of the entity object is sometimes being updated (i.e. an old instance of the order entity is being
    picked up and updated on the database).
    2) We sometimes get a TransactionRequired exception thrown when we have concurrent updates to two different
    objects of the entity bean.
    Any idea as to what our problem could be?
    Thanks in advance for your help,
    The following are the main code snippets:
    Original Code
    Session Bean A
    Method 1 --- gets entity Bean B and calls a method on a different object passing this entity bean
              in as a parameter to enable a method on this bean to be called.
    EntityBean lOrderEntity = findOrderEntity(callerUnixLogin, currOrderId);
                   currOrder = lOrderEntity.getOrder();
                   //Logic to update the currOrder object via a method call.
                   persistManager.persistOrder(lOrderEntity, callerUnixLogin, currOrder, psTransactionType);
         persistManager.persistOrder Method:
                   lOrderEntity.setOrder(callerUnixLogin, order);
         findOrderEntity method:
    OrderEntity lOrderEntity = null;
              OrderEntityBeanPK orderPK = new OrderEntityBeanPK(orderId);
              try
                   if (orderEntityHome == null)
                        connectToOrderEntityBean(callerUnixLogin);
                   lOrderEntity = orderEntityHome.findByPrimaryKey(orderPK);
              ... etc
    Current Code
    Session Bean C
    Method 2 ---- calls method 1 in Session Bean A
    Calls to method 2 above happens in quick succession.
    OrderEntityBean class
    ... important methods ...
         private Order order = null;
         public OrderEntityBeanPK ejbFindByPrimaryKey(OrderEntityBeanPK primaryKey)
              throws FinderException, RemoteException, DBOException
              try
                   orderObjectManager.orderIdExists(primaryKey.orderId);
              catch (OMOrderValidationException exc)
                   throw new FinderException(exc.getMessage());
              return primaryKey;
         public void setOrder(String userUnixLogin, Order newOrder)
              throws EJBException, RemoteException, DBOException, OMFormattingException, OMOrderValidationException
              callerUnixLogin = userUnixLogin;
              int version = newOrder.getOrderVersion().intValue();
              if (order.getOrderVersion().intValue() == version)
                   order = null;
                   order = newOrder;
                   Integer newVersion = new Integer(version + 1);
                   order.setOrderVersion(newVersion);
                   newVersion = null;
                   order.setSysUser(callerUnixLogin);
                   orderObjectManager.updateOrder(callerUnixLogin, order);
              else
                   Debug.Print(userUnixLogin, "OrderEntityBean.setOrder: wrong version number for order " + newOrder.getOrdId() +
                        ": expected " + order.getOrderVersion() + " and got " + newOrder.getOrderVersion(), 0);
                   throw new OMOrderValidationException("wrongVersion", order, order.getOrdId(), IName.Order.VERSION, newOrder.getOrderVersion());
         public Order getOrder()
              throws EJBException, RemoteException
    return ((Order)order.clone());
    The following transactions exists for the entity bean ...
    Required:
         create and setOrder methods
    Not Supported
         findByPrimary and getOrder methods

    "The entity bean has a "void setOrder(Order param)" function that writes the Order to a database"
    This functionality should be performed in the ejbStore method().
    "a "Order getOrder()" function that clones and returns the internal Order object."
    Sounds reasonable, except for the cloning part.
    "The "ejbLoad()" function reads the Order object from the database"
    Cool.
    ""ejbStore()" function is not implemented."
    Whoops. Looks like your setOrder method is doing too much. It should do the inverse of getOrder (namely, setting the interal Order object), nothing more. Defer the persistence code to the ejbStore method.
    "According to the SilverStream manual it does not maintain a pool of idle/unused entity beans, instead it instantiates beans as requested."
    Manual? What's that? Assuming that is correct, better hope you don't ever get a high load. You might wanna look into JBoss.
    "2) We sometimes get a TransactionRequired exception thrown when we have concurrent updates to two different objects of the entity bean."
    How can you have concurrent access to two different objects?? Concurrency is inherently applicable to only one object.
    In summary:
    Write your beans properly, ejbLoad populates the bean with data, ejbStore persists the bean's data.
    Get a better (and possibly free) appserver.

  • Regarding ENTITY bean local interfaces

    Hi all,
    I have a component session bean - containing a number of service methods for creating, retrieving, updating & deleting instances of a related entity bean. This session bean is used by another session facade bean, which invokes the various service methods in some sequence to complete a major task.
    In the component session bean, the retireve methods return the local interface of the entity bean - on which it operates. The update methods accespt local interfaces of entity bean which can be directly updated.
    My question is : Is it a right approach to pass the entity bean instances between method calls.
    Thanks in advance,
    Baskar

    Your pointers regarding pt 2 was nice. Thanks.
    This being my first J2ee design, I'am just collecting as much information as possible to stay confident.
    Later, I started thinking a bit more regarding pt 1.
    Where, I decided using individual session beans for different components(representing unique functionalities).
    i.e,, I'am just thinking, should I use individual session beans for each of these different components.
    What if I use standard java classes - implementing pre-defined interfaces for each of these components & use the components through these interfaces in session facade.
    Now, I'll be using entity bean creates/retrieves/updates/deletes from inside normal java classes.
    I thought, this would obviate the need for JNDI lookups - each time I want to use the components in my session facade.
    But, I'am not sure of where this will impact..As far as I can visualize, this seems to be normal. Please share ...your thoughts regarding this. (something regarding transactions ??)

  • Calling Stateful & Statless Methods from the same Entity Bean[EJB2.0]?

    Dear All,
    We using EJB2.0........
    Regarding segregation of stateless and stateful methods..These methods are defined in Session bean.Now my question is
    Is it a good practice to call Stateful and Stateless business methods from same single entity bean("EntityBean") defined at program level by extending MainBean..
    The architecture is like
    public class EntityBean extends MainBean
    Public Methodxyz
    stfobj.MakeConn();
    stlobj.getXyz();
    stfobj.CloseConn();
    Public Class MainBean{lookup("stl");lookup(stf) ;stl_obj=home.create;stf_obj=home.create()............}
    ejb-jar.xml
    { <session>
              <description>Entity Bean Employee Example</description>
              <ejb-name>stl</ejb-name>
              <local-home>com.packg.stlHome</local-home>
              <local>com.packg.stl</local>
              <ejb-class>com.packg.stlBean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Container</transaction-type>
         </session>
         <session>
              <description>Entity Bean Employee Example for stateful</description>
              <ejb-name>stf</ejb-name>
              <local-home>com.packg.stfHome</local-home>
              <local>com.packg.ejbeans.stf</local>
              <ejb-class>com.packg.stfBean</ejb-class>
              <session-type>Stateful</session-type>
              <transaction-type>Container</transaction-type>
         </session>
         <session>
              <description>Session bean for System Parameters</description>
              <ejb-name>SysParam</ejb-name>
              <local-home>com.packg.Home</local-home>
              <local>com.packg.Param</local>
              <ejb-class>com.packg.Bean</ejb-class>
              <session-type>Stateless</session-type>
              <transaction-type>Bean</transaction-type>
              <ejb-local-ref>
              <ejb-ref-name>stl</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <local-home>com.packg.stlHome</local-home>
              <local>com.packg.ejbeans.stl</local>
              <ejb-link>stl</ejb-link>
         </ejb-local-ref>
              <ejb-local-ref>
              <ejb-ref-name>stf</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <local-home>com.packg.stfHome</local-home>
              <local>com.packg.stf</local>
              <ejb-link>stf</ejb-link>
         </ejb-local-ref>
         </session>
    Thanks !!
    Edited by: user9052593 on Jun 18, 2012 2:20 AM
    Edited by: user9052593 on Jun 18, 2012 2:25 AM

    All Business logic resides in session beans[Stateful or Stateless]..For stateful beans we are opening connections in entity bean ,calling business methods and closing connection in entity bean itself..Problem is
    I am doing lookup for stateful and stateless both since both objects are called by extending MainBean in same entity bean else will give null pointer exception..
    So whenever i call a Stateful or Stateless method from entity bean Which ultimately extends/calling MainBean and thereby calling home.create methods of stateful and stateless both..creating objects..Is this way fine or it will affect the performance?
    Do i need to segregate the Calls/invokation to Stateful / Stateless methods at entity bean level too..
    For ex:- Whenever i call Methodxyz() method ..at the same time it create 2 objects as its extending MainBean...i want to extend/create 1 object either of stateful or stateless one for stateful and stateless methods call respectively..
    See the code in entity bean is like
    public class EntityBean extends MainBean
    Public Methodxyz
    stfobj.MakeConn(); call to stateful method defined in stateful bean
    stlobj.getXyz();// call to stateless method defined in stateless bean
    stfobj.CloseConn(); call to stateful method defined in stateful bean
    ------------------------------------------------------------

  • Database access using Entity Beans

    How does it work? In the examples I've seen, there is no SQL statement
    being generated, and I no code establishing the JDBC bridge...
    What am I missing? How do I look up a record in a database using an
    entity bean?
    Thanks!!!
    -Dan

    The Entity Bean remote interface methods access the database.
    InitialContext ic=new InitialContext();
    EntityBHome eh = (EntityBHome)ic.lookup("com.ejb.EntityBHome");
    EntityB entityB=eh.findByPrimaryKey(primarykey pk);
    [email protected] (Dan M) wrote:
    How does it work? In the examples I've seen, there is no SQL statement
    being generated, and I no code establishing the JDBC bridge...
    What am I missing? How do I look up a record in a database using an
    entity bean?
    Thanks!!!
    -Dan

  • Does CMP bean finder method supports "LIKE" sql?

    I put something like this in the orion-ejb-jar.xml file:
    <finder-method partial="false" query="select * from EMP where $ename like $1 AND $job like $2">
    </finder-method>
    If I put in exact value like 'ADAMS' or 'CLERK', it works fine. But if I put in 'A%' or 'CL%', it does not work. I know the record is there and the same sql does return a row in sql-plus.
    Appreciate any help.
    Adam

    I put something like this in the orion-ejb-jar.xml file:
    <finder-method partial="false" query="select * from EMP where $ename like $1 AND $job like $2">
    </finder-method>
    If I put in exact value like 'ADAMS' or 'CLERK', it works fine. But if I put in 'A%' or 'CL%', it does not work. I know the record is there and the same sql does return a row in sql-plus.
    Appreciate any help.
    Adam gday Adam -
    I don't think there is anything in the persistence manager that will prevent this from working as you want.
    Can I ask what version of OC4J you are using?
    I'm not sure from your email if you are you specifying the fields in the finder method by surrounding them with SQL style quotes as in 'A%'? You shouldn't need to do that if you are.
    I just tested it out with a simple client and entity bean based on the employee table, which I created in about 30 seconds with the new JDeveloper CMP Entity Bean Wizard, using the create from existing table option.
    I added a finder method that looks like the following:
    Collection findByEnameAndJob(String ename, String job) throws RemoteException, FinderException;
    And then changed the SQL in the finder dialog (or orion-ejb-jar.xml) for the finder to be
    <finder-method partial="False" query="select * from emp where $ename like $1 and $job like $2">
    <method>
    <ejb-name>Emp</ejb-name>
    <method-name>findByEnameAndJob</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    <method-param>java.lang.String</method-param>
    </method-params>
    </method>
    </finder-method>
    The client code then looked for employees with a name starting with the letter A and whose job started with the letters CL as follows:
    Collection coll = empHome.findByEnameAndJob("A%","CL%");
    System.out.println("*** There were : " + coll.size() + " records returned ***");
    Iterator iter = coll.iterator();
    while (iter.hasNext())
    emp = (Emp)iter.next();
    System.out.println("empno = " + emp.getEmpno());
    System.out.println("ename = " + emp.getEname());
    When the client was run, this was the resulting output:
    *** There were : 1 records returned ***
    empno = 7876
    ename = ADAMS
    job = CLERK
    mgr = 7788
    hiredate = 1987-05-23 00:00:00.0
    sal = 1100
    comm = 0
    deptno = 20
    If you want to find all the entries that have a job that starts with CL you can even use the same finder method like:
    Collection coll = empHome.findByEnameAndJob("%","CL%");
    This results in the output
    *** There were : 4 records returned ***
    empno = 7369
    ename = SMITH
    job = CLERK
    mgr = 7902
    hiredate = 1980-12-17 00:00:00.0
    sal = 800
    comm = 0
    deptno = 20
    empno = 7876
    ename = ADAMS
    job = CLERK
    mgr = 7788
    hiredate = 1987-05-23 00:00:00.0
    sal = 1100
    comm = 0
    deptno = 20
    empno = 7900
    ename = JAMES
    job = CLERK
    mgr = 7698
    hiredate = 1981-12-03 00:00:00.0
    sal = 950
    comm = 0
    deptno = 30
    empno = 7934
    ename = MILLER
    job = CLERK
    mgr = 7782
    hiredate = 1982-01-23 00:00:00.0
    sal = 1300
    comm = 0
    deptno = 10
    I can send you the packaged EAR file if you want to try this simple example for yourself - or you I would even encourage you to grab JDeveloper 9i and see how it easy it makes it to build and test the example I was just working with.
    cheers!
    -steve

Maybe you are looking for

  • In Photoshop CS5 why does Camera Raw 6.7 not open a Crw Raw Image?

    I am running Windows XP Pro 32 bit system,with AMD ALthon  2600 processor.When I first installed Photoshop CS5 it would not open at all.After hours on the internet searching for online help from Adobe,L came across a on line chat.They said I needed a

  • Windows Vista cannot read the file in my ipod touch

    I am using windows vista and I have 2 separate problems with my ipod touch: 1. Itune recognizes my ipod and all the songs that are on it but not the photos. 2. Windows cannot display the files that are on the device. When I go to my computer the ipod

  • Cs6 how to make 2d map come out of 3d earth

    Hiya. I have a pic of earth...like this... and a map graphic like this... the background of both images is alpha ( transparent ). I wanna put the map over the earth and bend it so it conforms to the earth shape kinda close to the the scale and positi

  • Navigate to another page in the same window problem

    Hi, I have a problem with the following scenario: When a user clicks on a link in a portal, a web dynpro page opens in new window with the url similar to this http://server:port/irj/servlet/prt/portal/prtmode/runtime/prtroot/pcd!3aportal_content!2fCo

  • Problem when trying to update Nokia Maps 2.0

    Hello, I have installed Nokia Maps 2.0, however, the Nokia Store informs me that there is an update to the Maps application. After installing the update the application remains the same and the Nokia Store returns to inform me that there is an update