Use direct JDBC with CMP entity bean in one transaction

I am trying to use direct JDBC call with CMP entity bean within a session
bean method that requires transaction. The problem is that it appears these
are not in the same transaction. When I use the JDBC call, the CMP entity
bean update to the DB has not been committed yet.
We are using Weblogic 5.1 SP6. The DB is Oracle.
What I do for the JDBC is get a new connection from the pool using weblogic
jdbc pool driver.
Any help would be appreciated.
Patrick

Hi. You can do JDBC and invoke CMP EJBs and have this all treated
as one transaction, if your hand-written code explicitly starts
a JTS transaction, then uses the jts driver or a TxDataSource to
get the JDBC connection. Then your code can call transactional
EJBs and their work will be included in the transaction you started.
Assuming the bean work went OK, and your manual JDBC went OK, you
can manually commit the UserTransaction at that time. This is 5.1
talk. For 6.0, with @PC, this may be even easier...
Joe
Patrick Shen wrote:
>
But if I do that, then they would not be in the same transaction anymore.
Is there any way to use JDBC with CMP Entity bean in the same transaction?
Patrick
"L'artiste" <[email protected]> wrote in message
news:[email protected]...
Are you calling all the CMP create in the session Bean ? If so, beforeyou
make the JDBC call from the session bean, the CMP in 2. should commit. Try
to set its attribute to TX_REQUIRES_NEW. This way, the calling client will
block until this transaction is done (committed) before the execution
continues. There might be some overhead involved in doing so if you are
anticipating a lot of users.
"Patrick Shen" <[email protected]> wrote in message
news:[email protected]...
What I am trying to do is:
In a Session bean method -
1. create a new CMP entity bean (a new row in DB table)
2. create another new CMP entity bean that uses previous bean as foreignkey
3. use JDBC to update the row just created
And all these 3 calls have to be in one transaction.
Thanks,
Patrick
"L'artiste" <[email protected]> wrote in message
news:[email protected]...
Can you give a little bit more information?
Do you have methods in your session bean that creates this CMP entitybeans?
It looks like
you might wanna try to change the isolation level to
TRANSACTION_READ_COMITTED
to preven dirty_read.
"Patrick Shen" <[email protected]> wrote in message
news:[email protected]...
I am trying to use direct JDBC call with CMP entity bean within a
session
bean method that requires transaction. The problem is that it
appears
these
are not in the same transaction. When I use the JDBC call, the CMP
entity
bean update to the DB has not been committed yet.
We are using Weblogic 5.1 SP6. The DB is Oracle.
What I do for the JDBC is get a new connection from the pool usingweblogic
jdbc pool driver.
Any help would be appreciated.
Patrick
PS: Folks: BEA WebLogic is expanding rapidly, with both entry and advanced positions
for people who want to work with Java, XML, SOAP and E-Commerce infrastructure products.
We have jobs at Nashua NH, Liberty Corner NJ, San Francisco and San Jose CA.
Send resumes to [email protected]

Similar Messages

  • What are the necessary elements in ejb-jar.xml with CMP entity bean

    What are the necessary elements in ejb-jar.xml with CMP entity bean
    Actually i am using webligic 8.1 and while deployment getting the error that
    some elements r missing
    Thanks
    Anand Pritam

    According to the ejb-jar.xml dtd ejb-name, ejb-class, persistence-type, prim-key-class, reentrant are the required elements for an entity bean.
    <!ELEMENT entity (description?, display-name?, small-icon?,
              large-icon?, ejb-name, home?, remote?, local-home?,
              local?, ejb-class, persistence-type, prim-key-class,
              reentrant, cmp-version?, abstract-schema-name?,
              cmp-field*, primkey-field?, env-entry*, ejb-ref*,
              ejb-local-ref*, security-role-ref*, security-identity?,
              resource-ref*, resource-env-ref*, query*)>

  • Can't Update with CMP entity bean (psi-ri)

    Hello!
    Has anybody got entitybeans to work thorougly with psi-ri -persistence provider?
    Our entities Insert and Delete as they should be, but we haven't got them to Update anything.
    I have a feeling that this has something to do with transactions, but I haven't found any answers yet.
    All help is more than appreciated
    Petri Valto
    null

    yes, Entity beans with psi-ri works fine. In fact I have written a couple of them which is fine.

  • Little Help with CMP Entity Bean

    I have the following error:
    --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
    ObjectName: jboss.j2ee:service=EjbModule,module=SISEPROEJB.jar
      State: FAILED
      Reason: org.jboss.deployment.DeploymentException: Atleast one role of a
    foreign-key mapped relationship must have key fields (or <primkey-field> is
    missing from ejb-jar.xml): ejb-relation-name=Abogado-to-AdmninistrativoI have two entity beans called abogado and adminsitrativo, the relation is abogado-has-many-adminitrativo, (one-to-many)
    Here is my xdoclet code in abogado:
             * @ejb.interface-method
             * @ejb.relation
             *    name="Abogado-to-Administrativo"
             *    role-name="Abogado-has-many-Administrativo"
             *    target-ejb = "Administrativo"
             *    target-role-name = "Administrativo-has-one-Abogado"
             * @jboss.target-relation related-pk-field = "userName"
             *    fk-column = "UserName_id_fk"
             * @return Collection de procesos administrativos
             public abstract Collection getProcesos();Here is the xdoclet code for administrativo
             * @ejb.interface-method
             * @ejb.relation name="Abogado-to-Admninistrativo"
             *    role-name="Administrativo-has-one-Abogado"
             *    target-ejb="Abogado"
             *    target-role-name="Abogado-has-many-Administrativo"
             *    target-multiple="true"
             * @return
             public abstract AbogadoLocal getAbogado();Both beans have pk fields defined with:
         * @ejb.persistence column-name = "id"
         * @ejb.pk-fieldand
         * @ejb.interface-method
         * @ejb.persistence column-name = "UserName"
         *     sql-type="VARCHAR"
         * @ejb.pk-fieldPlease help me I have been stuck here for the whole weekend.
    Thanks
    Daniel Castro

    Try the following forum (about EJB technology)
    http://forum.java.sun.com/forum.jspa?forumID=13

  • Open jdbc connections with CMP entity beans

    Hi,
    Seem to always have open connections (generally about half those that have been opened) when using CMP beans. How can i make sure these get closed when my app is finished with them ??
    Thanx
    Rosie

    Hi,
    Seem to always have open connections (generally about half those that have been opened) when using CMP beans. How can i make sure these get closed when my app is finished with them ??
    Thanx
    Rosie

  • RE: Consuming and Creating a CMP Entity Bean

    Hi There,
    I have been trying to find an answer for 1 day. I don't know ehre to look next.
    I am creating a CMP entity bean. I have created all the set and get mehtods as abstract functions. I have added a ejbCreate and a matching ejbPostCreate. The class code looks like this.
    public abstract class COrderBean implements EntityBean {
         protected EntityContext entctx;
         //abstract declarations of property accessors
         public abstract int getId();
         public abstract void setId(int intid);
         public abstract String getCustomerID();
         public abstract void setCustomerID(String strcustomerid);
         public abstract Date getDate();
         public abstract void setDate(Date datorder);
         public abstract String getNotes();
         public abstract void setNotes(String strnotes);
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void ejbRemove() {}
         public void ejbLoad() {}
         public void ejbStore() {}
         public void setEntityContext(EntityContext context)
              entctx = context;
         public void unsetEntityContext()
              entctx = null;
         public COrderPK ejbCreate()
              return null;
         public COrderPK ejbCreate(int new_id, String new_customerid, Date new_order_date, String new_notes) throws CreateException
              setId(new_id);
              setCustomerID(new_customerid);
              setDate(new_order_date);
              setNotes(new_notes);
              return new COrderPK(getId());
         public void ejbPostCreate(int id, String customerid, Date order_date, String notes) {}
    My client code works with both BMP entity beans and session beans. It is shown below. I am working with Sun's Application Server 8.0 and I created the database schema with the capture-schema.exe command.
    Properties prps = new Properties();
              props.put("javax.rmi.CORBA.UtilClass","com.sun.corba.ee.impl.javax.rmi.CORBA.Util");
              props.put("org.omg.CORBA.ORBClass","com.sun.corba.ee.impl.orb.ORBImpl");
              props.put("org.omg.CORBA.ORBSingletonClass","com.sun.corba.ee.impl.orb.ORBSingleton");
              Context context = new InitialContext(props);
              Object obj = context.lookup("corbaname:iiop:localhost:3700#COrderBean");
              //Object obj = context.lookup("entitybean.OrderItem");
                   IOrderHome home = (IOrderHome)PortableRemoteObject.narrow(obj,Class.forName("ctaejb.entitybean.order.IOrderHome"));
                   //use create
                   IOrderRemote remote = home.findByPrimaryKey(new COrderPK(1));
                   System.out.println(remote.getDate().toString());
    I am getting the follwing error. Can someone please help. Thanks in advance.
    WARNING: "IOP00810257: (MARSHAL) Could not find class"
    org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
         at com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:7987)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1013)
         at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:259)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputObjectField(IIOPInputStream.java:1989)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputClassFields(IIOPInputStream.java:2213)
         at com.sun.corba.ee.impl.io.IIOPInputStream.inputObject(IIOPInputStream.java:1221)
         at com.sun.corba.ee.impl.io.IIOPInputStream.simpleReadObject(IIOPInputStream.java:400)
         at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValueInternal(ValueHandlerImpl.java:330)
         at com.sun.corba.ee.impl.io.ValueHandlerImpl.readValue(ValueHandlerImpl.java:296)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1034)
         at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:879)
         at com.sun.corba.ee.impl.encoding.CDRInputStream.read_value(CDRInputStream.java:255)
         at com.sun.corba.ee.spi.servicecontext.UEInfoServiceContext.<init>(UEInfoServiceContext.java:30)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at com.sun.corba.ee.spi.servicecontext.ServiceContextData.makeServiceContext(ServiceContextData.java:114)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.unmarshal(ServiceContexts.java:195)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:365)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:470)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:327)
         at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:158)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at ctaejb.entitybean.order._IOrderHome_DynamicStub.findByPrimaryKey(_IOrderHome_DynamicStub.java)
         at mainapp.CTestApplication.main(CTestApplication.java:32)
    Caused by: java.lang.ClassNotFoundException
         ... 27 more
    org.omg.CORBA.UNKNOWN: vmcid: 0x0 minor code: 0 completed: Maybe
         at com.sun.corba.ee.spi.servicecontext.UEInfoServiceContext.<init>(UEInfoServiceContext.java:34)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
         at com.sun.corba.ee.spi.servicecontext.ServiceContextData.makeServiceContext(ServiceContextData.java:114)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.unmarshal(ServiceContexts.java:195)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:365)
         at com.sun.corba.ee.spi.servicecontext.ServiceContexts.get(ServiceContexts.java:353)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.processResponse(CorbaClientRequestDispatcherImpl.java:470)
         at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.marshalingComplete(CorbaClientRequestDispatcherImpl.java:327)
         at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.invoke(CorbaClientDelegateImpl.java:158)
         at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:129)
         at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(Unknown Source)
         at ctaejb.entitybean.order._IOrderHome_DynamicStub.findByPrimaryKey(_IOrderHome_DynamicStub.java)
         at mainapp.CTestApplication.main(CTestApplication.java:32)

    Forget it. All the code works. I didn't know that the Sun App Server required a Persistence Manager to work with CMP entity beans. Once I added the persistence manager, all was OK. Have a good day.

  • Help about Date and Time by CMP entity bean

    I should have two fields in my cmp .one stores current date ,another one stores current time while ejbcreate();
    I should be able to get findmethod findobjectBetween ?! and ?2
    or that sorts of find method.what type of the method should I use.
    java.util.Date or Simply String?
    if I use java.tuil.Date as the type.
    How shoud my ejbcreate method look like?
    public abstract void setDate(Date mydate);
    public abstract Date getDate();
    ejbCreate(String name,String password,Date mydate,Date mytime)
    setDate()
    I suppose I use write a business method getCurrentDate() which uses
    java.util.Date().toLocale,But I think it just returns String
    help pls.

    I am using oc4j(Oracle9iAS (9.0.3.0.0))
    I am getting the following error using Timestamp while deploying cmp entity bean ejb1.1. Thanks...
    Auto-deploying TimestampTestEntity.jar (No previous deployment found)... TimestampTest_EntityBeanWrapper0.java:1558: Missing term.
    if (if(thread.contextContainer != null)
    ^
    TimestampTest_EntityBeanWrapper0.java:1558: ')' expected.
    if (if(thread.contextContainer != null)
    ^
    TimestampTest_EntityBeanWrapper0.java:1559: Invalid expression statement.
    response != null) {if(thread.contextContainer != null)
             ^
    TimestampTest_EntityBeanWrapper0.java:1559: ';' expected.
    response != null) {if(thread.contextContainer != null)
                    ^
    TimestampTest_EntityBeanWrapper0.java:1560: Missing term.
    response.setNanos(if(thread.contextContainer != null)
                      ^
    TimestampTest_EntityBeanWrapper0.java:1560: ')' expected.
    response.setNanos(if(thread.contextContainer != null)
                      ^
    TimestampTest_EntityBeanWrapper0.java:1561: ';' expected.
    response.getNanos());} // generated from BeanMethodCompilation
    ^
    7 errors
    Error compiling F:\oc4j\j2ee\home\applications\TimestampAppl/TimestampTestEntity.jar: Syntax error in source
    Oracle9iAS (9.0.3.0.0) Containers for J2EE initialized

  • How to use same transaction when calling CMP entity beans and  DAO (JDBC)

    We are currently using Weblogic 8.1 SP2 with an Oracle 10g database (using XA thin and non-XA drivers).
    We have a session bean that invokes an entity bean and a DAO (data access object pattern) in order to add data in 2 separate tables (account and history). Rows are added to the first (account) table using a CMP Entity bean while inserts are done in the 2nd (history) table using a DAO. Here is some pseudo code:
    addHistorySessionBean (trans-attribute="Required")
    begin
    Step #1 - call addAccountEntityBean (trans- attribute="Required")
    Step #2 - call addHistoryDAO (get datasource, connection)
    end
    The 2nd table (history) has a foreign key constraint to ensure that the corresponding key exists in the first (account) table. Unfortunately, DAO inserts on the 2nd (history) table fail with a foreign key constraint violation (INTEGRITY CONSTRAINT VIOLATION - PARENT KEY NOT FOUND!) since they cannot see the row added to the 1st (account) table in step #1 by the CMP entity bean.
    How does one ensure that all this is done in a single transaction ? It appears that the app server creates two seperate transactions (one for the session bean facade and the entity bean and a 2nd transaction (when we retrieve a connection using the same data source JNDI name) for the DAO.
    A post on server side suggested using a "<resource-ref>" in the session bean to tie the two potentially separate transactions together, but that does not work for us. However, I am not sure if we are doing that correctly. After we define the resource ref in the session facade bean, do we use the resource ref "name" attribute to lookup the datasource or do we still lookup the datasource by JNDI name ? Do we need to define the resource-ref tag in the entity bean also ?
    Does Weblogic allow using a single transaction for this type of a scenario ? How does one specify within Weblogic that the same transaction should be utilized by the entity bean and any subsequent DAOs?
    People have also suggested that we defer constraint checking until the transaction(s) are committed but that sounds like a work acount without addressing this issue. Would postponing the constraint checking in Oracle cause any additional overhead ?
    Any suggestions with specific examples or documentation on how to address this issue will be gratefully appreciated.

    Thanks for your suggestion. Unfortunately, this does not work since it appears that there are 2 separate transactions going on here. One, the original one initiated by the session bean and used by the entity bean and the other initiated by the DAO. Any other ideas appreciated.
    Hi,
    Try setting the delay-database-inserts tag to
    ejbCreate in RDBMS descriptor file.
    http://bernal/stage/wls/docs81/ejb/DDreference-cmp-jar
    .html#1113981
    vasanthi ramesh

  • Error while using sybase trigger with the CMP entity bean,ejb version 2.1

    Hi All,
    I am using ejb version 2.1 and using entity bean (Transaction required) ,i am trying to update data in sybase(ver 12.3) database table
    I am using session bean(Transaction required) to update the multiple entity beans in a while loop.It is working fine .But when i am trying to run it with the trigger which updates multiple tables in different sybase databases on update of each entity.Then it throws NoSuchEntityException and it rollback the whole transaction.
    My trigger has only few simple update statements and the trigger runs fine without my CMP entity bean.is the CMP does not support the update triggers in sybase or is it the problem with the transaction.
    Please help
    Thanks
    Anshu

    If you can have a look at a cmp example in the samples that ship with the server. My guess is that the weblogic-ejb-jar.xml file is missing the <persistence-use> element which for 810 would look like:
    <persistence>
    <persistence-use>
    <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
    <type-version>7.0</type-version>
    <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
    </persistence-use>
    </persistence>
    I seem to recall that the elements might be slightly different in structure for the wls700 version of the DTD, so please check that (I cannot, I'm at home and don't have everything here).
    Give that a try and see if it doesn't solve your compilation failure.
    Also, the compilation should not be throwing a null pointer exception in a case like that, I consider that to be a bug.
    -thorick

  • Bad Performance/OutOfMemory Error in CMP Entity Bean with Large DB

    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() - (Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP Entity Beans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

    Hi
    You should use a Select Method, it does support cursors.
    Or a Home Select Method combination.
    Regards
    Thomas
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>>
    (without max-beans-in-cache directive the performance is worse)>
    Is there any documentation available to help us in deploying CMP
    Entity Beans with very large number of records (instances) ? Any help
    is greatly appreciated.>
    Regards>
    Rajan>
    >
    "Rajan Jena" <[email protected]> schrieb im Newsbeitrag
    news:3dadd7d1$[email protected]..
    >
    Hello:
    I have an CMP Entity deployed on WLS 7.0
    The entity bean maps to a table that has 97,480 records.
    It has a finder: findAll() -- SELECT OBJECT(e) FROM Equipment e
    I have a JSP client that invokes the findALL()
    The performance is very poor ~ 150 seconds just to perform the findAll() -(Benchmark
    from within the JSP code)
    If more than one simultaneous call is made then I get outOfMemory Error.
    WLS is started with max memory of 512MB
    EJB is deployed with <max-beans-in-cache>100000</max-beans-in-cache>
    (without max-beans-in-cache directive the performance is worse)
    Is there any documentation available to help us in deploying CMP EntityBeans
    with very large number of records (instances) ?
    Any help is greatly appreciated.
    Regards
    Rajan

  • Using a CMP Entity Bean local stub as a field of another CMP Entity Bean

    Hello,
    Is it possible to implement a field of a CMP Entity bean as another CMP Entity bean and how is it done?
    I've seen a pseudo code for this in Ed Roman's Mastering EJBs, second edition, but I can't seem to get it to work (pages: 330 - 1:1 using CMP and 339 - fake M:N using CMP).
    I'm using SUN ONE Application Sever 7. Is this server capable of this?
    I'm trying to implement a fake M:N relationship using 3 beans: 2 for each side of the relationship and one as the "bridge" table.
    For example, the two beans on each side of the relationship are SubscriberBean, SubscriptionBean and the "bridge: bean is SubscriberSubscriptionBean. The SubscriberSubscriptionBean has two fields: SubscriberLocal stub and SubscriptionLocal stub.
    Please let me know if you need more information to answer this question.
    Thanks.
    Nikola

    Im sorry but i dont know about the example you are talking about. I kinda learn
    all those techniques from forums, articles and tutorials because book often suffer from
    not having the information im mostly looking for.
    As far as i understand you, you want to implement a bridge been, which is representing a row in a join table. So that if one side of the relation is deleted the join-table entry (your bridge-CMP-Bean) is cascaded. Right?
    First of all the simple part: (My approach)
    - The joint table is foreign keys only - without a relation description. -
    In this case you dont have to implement a bridge bean. Because it just wouldnt represent anything of sense.
    Lets think of an entity/table USER whith the columns name (PRIMARY KEY), and prename.
    Our second entity/table is ADDRESS with the columns road (PRIMARY KEY) and housenr.
    The join table is simply: USER_ADDRESS with fk_name (FOREIGN KEY) and fk_road (FOREIGN KEY) both on CASCADE DELETE. So if the address is deleted the mapping entry is deleted, too same for the user part:
    USER -> USER_ADDRESS <- ADDRESS.
    Our entity Beans are called User and Address in class-names JNDI-names and names.
    Now we want to create the CMR mapping so we can access the addresses of a user from the user bean directly. The methods on the user side are:
    public abstract Collection getAddresses();
    and
    public abstract void setAddresses(Collection new_addresses);
    the xdoclet comments on the User side are (for the getter only)
    * @ejb.interface-method
    * @ejb.relation
    *                name = "User-has-Addresses"
    *                role-name = "User-Addresses"
    *                target-ejb = "Address"
    *                target-multiple = "true"
    * @sunone.relation
    *                column="USER_ADDRESS.fk_name"               
    *                target="USER_ADDRESS.fk_road"               
    public abstract Collection getAddresses();
    for the other side of the relation we define in the Address-Entity
    public abstract Collection getUsers();
    and
    public void setUsers(Collection users);
    the xdoclet comments on the Address side are (for the getter only)
    * @ejb.interface-method
    * @ejb.relation
    *                name = "User-has-Addresses"
    *                role-name = "Address-User"
    *                target-ejb = "User"
    *                target-multiple = "true"
    * @sunone.relation
    *                target="USER_ADDRESS.fk_road"               
    *                column="USER_ADDRESS.fk_name"
    As we dont want the user or address to be deleted if the other side of the relation is deleted we dont specify cascade-delete="yes" in the ejb.relation namespace.
    The sun-cmp-mappings.xml should now look like this:
    (For the User - side)
    <!-- Relationship User-has-Addresses, role User-Addresses -->
    <cmr-field-mapping>
    <cmr-field-name>addresses</cmr-field-name>
    <column-pair>
    <column-name>USER_ADDRESS.fk_name</column-name>
    <column-name>USER_ADDRESS.fk_road</column-name>
    </column-pair>
    </cmr-field-mapping>
    and similar on the Address-Side:
    <cmr-field-mapping>
    <cmr-field-name>users</cmr-field-name>
    <column-pair>
    <column-name>USER_ADDRESS.fk_road</column-name>
    <column-name>USER_ADDRESS.fk_name>/column-name>
    </column-pair>
    </cmr-field-mapping>
    Dont forget that all elements in the Collection must be of the right Interface-type.
    First of all the harder part:
    Now what you might want is when the relation has some information specified like user live at address and is tenant or facility manager.
    The, in the first step you will have to implement the UserAddressRelation entity which will have to CMR fields of the 1:N type.(Just as you wish)
    Lets think of the example above extended by the relation type. Our relation bean is named UserAddressRelation.
    Now User has the methods as above but the classes in the Collection must now be of the UserAddressRelationLocal/Remote interface and not AddressLocal/Remote-interface.
    You will have to change the xdoclet comment to:
    * @ejb.interface-method
    * @ejb.relation
    *                name = "User-has-Addresses"
    *                role-name = "User-Address"
    *                target-ejb = "UserAddressRelation"
    *                target-multiple = "true"
    * @sunone.relation
    *                target="USER_ADDRESS.fk_name"               
    *                column="USER.name"
    So we now dont reference the other side bean directly. We reference the relation EntityBean. Do the similar changes on the other side.
    In particular you will have to specify 4 CMR mappings now:
    1. User to UserAddressRelation 1:N
    2. UserAddressRelation N:1
    3. Address to UserAddressRelation 1:N
    4. UserAddressRelation N:1
    Which i dont want to explain in detail now because its kinda all the same as above.
    Now you cann access the Addresses of a user in the way.
    UserLocal.getAddresses(); <- !you get the mappings!
    UserLocal.getAddresses().item(0).getAddress() <- you get the address (this is dirty coding just for understanding)
    UserLocal.getAddresses().item(0).getUserRole() <. you get the role of the user at this address.
    Hope this helped you. You are welcome to ask any detailed question.

  • Using oracle db sequence for auto generating of PKs for CMP entity beans

    Hi,
    I have read quite a number of threads about (auto) generation of keys for primary keys for the CMP entity beans.
    My requirement is I am migrating an application deployed on Weblogic to oc4j. The application is using cmp entity beans with auto key generation using a sequence in the Oracle db. This is specified in weblogic-cmp-rdbms-jar.xml file like below:
    <automatic-key-generation>
    <generator-type>Oracle</generator-type>
    <generator-name>REPUSER.DEPT_REPORT_SEQ</generator-name>
    <key-cache-size>1</key-cache-size>
    </automatic-key-generation>
    In the ejb-jar.xml, it is specified as:
    <prim-key-class>java.lang.Integer</prim-key-class>
    <primkey-field>id</primkey-field>
    Now, I need to migrate this to oc4j. Can somebody suggest me options and clarify my questions kindly?
    1) I have read articles that say that in the ejb-jar.xml, we need to specify <prim-key-class>java.lang.Object</prim-key-class> and this will create a column called 'autoid' in the respective entity table in the Oracle db.
    - How can I use this to assign the value to my primary field, say, id?
    2) Now, with the latest oc4j, can I use Oracle database sequence as the key generator for the values of the PKs just by specifying in the xml descriptor ejb-jar.xml?
    2.a) If yes, is there any article that explains with the code?
    2.b) If no, what are the alternatives I have?
    I have read many discussions that say that we can create a stateless session bean that can lookup the database sequence using simple JDBC call to return the nextval of the sequence. The SSB should be called in the ejbCreate() of the entity bean.
    My related question is, what is recommended for oc4j? What are limitations of the various options for the latest oc4j available?
    How should I go about deploying this kind of ejbs in oc4j?
    Any help and pointers are welcome. Please help.
    Thanks a lot.
    Vadi

    Hello ,
    Instead of exposing a get/set method for each arribute of your bean (corresponding to database table) expose only one object.
    For example
    public class CustomerBean implements javax.ejb.EntityBean{
    private CustomerVO objCustomer;
    private String customerName;
    private String customerMail;
    private String customerType;
    public CustomerVO getCustomer(){
    return this.objCustomer;
    public void setCustomer(CustomerVO objCustomer){
    this.objCustomer = objCustomer;
    public void ejbStore(){
    customerName = objCustomer.getName();
    customerMail = objCustomer.getMail();
    customerType = objCustomer.getType();
    HTH
    VJ

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • ORA-01407 when removing a CMP Entity Bean with WLS 9.1

    Hi all !
    I hope you can help me to solve this ?:|
    I'm migrating my application from WLS 8.1 SP3 to WLS 9.1.
    I'm getting now an SQLException when I try to remove a CMP Entity Bean.
    The stacktrace is as follows:
    java.sql.SQLException: ORA-01407: cannot update ("USER"."MY_TABLE"."THE_CMR_FIELD") to NULL
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1120)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1278)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:128)
    Of course, I replaced the table and column names above to be more readable ;-)
    The table MY_TABLE has a CMR field called THE_CMR_FIELD. The column is not nullable in the database (by the way, it's an Oracle 9i).
    Everything is fine under WLS8.1
    I tried two different Oracle JDBC drivers (9.2.0.5 and 10.2.0.1.0), but the result is always the same within WLS9.1.
    Any ideas or suggestions (or even questions) are more than welcome!
    Thanks
    Eric

    What's even more weird is that I have what seams to be the same problem on Weblogic 6.1 (SP4).
    Here's the stacktrace:
    <pre>
    javax.ejb.EJBException:
    Start server side stack trace:
    java.sql.SQLException: ORA-01407: cannot update ("SCHEMA"."TIM_WP_DAY_CORE_PERIODS"."TWD_ID") to NULL
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
         at com.p6spy.engine.logging.P6LogPreparedStatement.executeUpdate(P6LogPreparedStatement.java:183)
         at weblogic.jdbc.jts.Statement.executeUpdate(Statement.java:503)
         at package.WorkPatternDayCorePeriods_vd9y46__WebLogic_CMP_RDBMS.__WL_store(WorkPatternDayCorePeriods_vd9y46__WebLogic_CMP_RDBMS.java:2317)
         at weblogic.ejb20.manager.DBManager.flushModified(DBManager.java:438)
         at weblogic.ejb20.internal.TxManager$TxListener.flushModifiedKeys(TxManager.java:552)
         at weblogic.ejb20.internal.TxManager.flushModifiedBeans(TxManager.java:298)
         at weblogic.ejb20.manager.BaseEntityManager.flushModifiedBeans(BaseEntityManager.java:1246)
         at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.flushModifiedBeans(RDBMSPersistenceManager.java:1106)
         at weblogic.ejb20.manager.BaseEntityManager.cascadeDeleteRemove(BaseEntityManager.java:840)
         at weblogic.ejb20.manager.DBManager.remove(DBManager.java:656)
         at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObject.java:97)
         at package.WorkPatternDayCorePeriodsEJB_vd9y46_ELOImpl.remove(WorkPatternDayCorePeriodsEJB_vd9y46_ELOImpl.java:722)
         at package.PersonWorkPatternBC.removeWorkPatternDay(PersonWorkPatternBC.java:571)
         at package.remove(PersonWorkPatternBC.java:708)
         at package.TimPersonCalendarServiceEJB.removeWorkPattern(TimPersonCalendarServiceEJB.java:140)
    </pre>
    In fact I have this setup:
    <pre>
    workpattern 1..n workpatternday -| 1..n dayperiod
    | 1..n daycoreperiod
    </pre>
    And before 'ejbRemove'ing the workpattern I first remove the days and before that the periods and core periods.
    I start with the periods and instead of removing them in the DB he tries to update the FK to the day with '' (p6spy result).
    When I remove the not null constraint on the foreign key everything passes to the day where the workpatternId cannot be set to null.
    He does not throw errors on the coreperiod (where the not null constraint to day is still present).
    When I invert the sequence of deleting
    (first the core periods then the 'regular' periods) he complains about the dayId on the core periods table.
    So it's completely absurd :S
    I hope weblogic 8.1 might solve this problem as this development code is still to be migrated to 8.1 before going in production...
    I would just like to know what's wrong. There are other places with just about the same relationships (CMR and DB) where he does not complain...

  • CMP Entity Bean's problem with MS-SQL Server 2000

    Hi everyone!
    I have a problem regarding CMP Entity Bean on OC4J.
    I made one CMP Entity Bean and deployed it to OC4J.
    It was successful.
    I used MS-SQL Server 2000 as Datasource.
    So, I installed MS-SQL Server's JDBC Driver and add some jar files to classpath.
    And I updated 'data-sources.xml' in OC4J's config directory.
    Then, I updated also 'orion-ejb-jar.xml' in my application's directory.
    I changed data-source's name to my data-source's name which use MS-SQL Server 2000.
    Finally, I started OC4J and EJB Client program which called Enitiy Bean's create method.
    But, The error occured which was 'Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence'.
    What's wrong? I need any helps.
    Here is stack overflow message. Thank you. Best regards.
    com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence.
         at UserHome_EntityHomeWrapper2.create(UserHome_EntityHomeWrapper2.java:1114)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
    at connection to localhost/127.0.0.1 as admin
         at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1530)
         at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1453)
         at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:53)
         at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
         at __Proxy0.create(Unknown Source)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.create(UserBeanTestClient1.java:73)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.<init>(UserBeanTestClient1.java:49)
         at com.emc.ksc.ejb.user.UserBeanTestClient1.main(UserBeanTestClient1.java:1077)

    Hi Young,
    From the information you have supplied, my guess is that the SQL
    string that OC4J is sending to SQL-Server is incorrect. So it may
    help if you could see the exact SQL string. In order to see the
    SQL string, I suggest you either run OC4J in "debug" mode, or try
    using "P6 Spy".
    The following web page has details on running OC4J in "debug" mode:
    http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
    And here is the web page for "P6 Spy"
    http://www.provision6.com/
    And these other web sites may also be of help (in general):
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.atlassian.com
    http://www.elephantwalker.com
    Good Luck,
    Avi.

Maybe you are looking for

  • Identification Specification missing in Source structure!!!

    Hi, I'm Saikumar. I'm doing LSMW (in that recording for MAP1 and MAP2 transactions). I've created 2 source structures ZMAP1_SOURCE and ZMAP2_SOURCE and also assigned some fields. I  created only one flat file for these 2 source structures and I've as

  • GRC 5.3 | ERM | Synch ERM - Back-End

    Hi Experts, suppose a role is generated in the back-end over ERM, it hence exists in both. If changes are made to the authorizations (e.g. deletion of a tcode, changed field value, ...) in the back-end, how can these then be synchronized automaticall

  • SAP Note 0001613410 not available

    Hi experts, when I try to download SAP Note 1613410 (SolMan 7.1 SP3) I get the error SAP Note 0001613410 not available. Has anybody a similar issue? I get the same message when I try to read the note in service marketplace.... Regards, Basti

  • I bought my iPhone 4s in Canada. Can I use it in Germany?

    I bought my iPhone 4s in Canada. Can I use it in Germany?

  • Name of War file

    Hi, I have a simple problem : I have a war file with a simple jsp in. If the name of war file is less than three characters, i can't called the JSP (HTTP 404) But if it's more than 3, it's work !!! Conf : Weblogic v6.1 Windows Why ? Thanks in advance