FindByPrimaryKey() problem

i am weblogic 7 and i have a problem when trying to call my bean's findByPrimaryKey() method. i get the error below when i tried a client that used that method.
opms.ejbs.facade.OPMSException: Exception while reading buildings.
Problem in findByPrimaryKey while preparing or executing statement: 'weblogic.jdbc.rmi.SerialPreparedStatement@35a25b':
java.sql.SQLException: No data found
java.sql.SQLException: No data found
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6207)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3261)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5393)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:321)
at weblogic.jdbc.jts.ResultSet.getString(ResultSet.java:84)
at weblogic.jdbc.rmi.internal.ResultSetImpl.getString(ResultSetImpl.java:178)
at weblogic.jdbc.rmi.internal.ResultSetStraightReader.getString(ResultSetStraightReader.java:37)
at weblogic.jdbc.rmi.SerialResultSet.getString(SerialResultSet.java:128)
at opms.ejbs.buildings.BuildingsBean_9zdi5b__WebLogic_CMP_RDBMS.__WL_loadGroup0FromRS(BuildingsBean_9zdi5b__WebLogic_CMP_RDBMS.java:810)
at opms.ejbs.buildings.BuildingsBean_9zdi5b__WebLogic_CMP_RDBMS.ejbFindByPrimaryKey(BuildingsBean_9zdi5b__WebLogic_CMP_RDBMS.java:640)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.cmp.rdbms.RDBMSPersistenceManager.findByPrimaryKey(RDBMSPersistenceManager.java:216)
at weblogic.ejb20.manager.BaseEntityManager.findByPrimaryKey(BaseEntityManager.java:755)
at weblogic.ejb20.manager.BaseEntityManager.remoteFindByPrimaryKey(BaseEntityManager.java:698)
at weblogic.ejb20.internal.EntityEJBHome.findByPrimaryKey(EntityEJBHome.java:367)
at opms.ejbs.buildings.BuildingsBean_9zdi5b_HomeImpl.findByPrimaryKey(BuildingsBean_9zdi5b_HomeImpl.java:102)
at opms.ejbs.facade.FacadeBean.readBuildings(FacadeBean.java:96)
at opms.ejbs.facade.FacadeBean_yoav96_EOImpl.readBuildings(FacadeBean_yoav96_EOImpl.java:1502)
at opms.ejbs.facade.FacadeBean_yoav96_EOImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:114)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:821)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)

i am weblogic 7 and i have a problem when trying to
call my bean's findByPrimaryKey() method. i get the
error below when i tried a client that used that
method.
opms.ejbs.facade.OPMSException: Exception while
reading buildings.
Problem in findByPrimaryKey while preparing or
executing statement:
'weblogic.jdbc.rmi.SerialPreparedStatement@35a25b':
java.sql.SQLException: No data found
java.sql.SQLException: No data found
As it clearly says there, data couldnt be found. Are you sure your entity bean has data in it ?
at
at
atRegards
Meka Toka

Similar Messages

  • FindByPrimaryKey(String problem), please help

    Hi everybody.
    I'm stuck for two days on this problem, and it's so weird I simply cannot find the solution. Here's the thing:
    I have an entity EJB ProductBean with a String as a primary key (on Weblogic 8.1 server and Oracle 10g database btw). Everything mapped succesfully, everything works nicely. I made an MDB and did this
    ProductHomeLocal productHome=(ProductHomeLocal)
    jndiContext.lookup("java:comp/env/ejb/ProductHomeLocal");          
    ProductLocal pl=productHome.findByPrimaryKey("ABC");Everything works nicely. Then I changed the last line so that the search parameter isn't hardcoded but sent by a JMS message parameter, like this:
    TextMessage tm = (TextMessage) msg;
    String productId=tm.getStringProperty("productId");
    ProductHomeLocal productHome=(ProductHomeLocal)
    jndiContext.lookup("java:comp/env/ejb/ProductHomeLocal");
    ProductLocal pl=productHome.findByPrimaryKey(productId); This results in a message:
    Bean with primary key 'ABC' was not found by 'findByPrimaryKey'...Why? The table data is there, if it's hardcoded it gets found no problem, why doesn't it work like this? What am I doing wrong?
    I appreciate any kind of help. Thanks in advance.

    I thought of leading and trailing spaces, it's not
    that.
    It seems that the problem isn't in JMS message, but
    in the fact that the entity bean somehow doesn't get
    "commited". The scenario is like this:
    - session bean creates the entity bean
    - session bean puts the entity bean's ID in JMS
    message
    - MDB bean gets the message and tries to get the
    entity bean with findByPrimaryKey(ID), fails.
    I know that this has something to do with
    transactions, but I really don't know how to solve
    it..Hmmm... assumming these 2 steps are in the same method in the session bean, then here's a possible scenario that can cause your problem,
    - session bean creates the entity bean
    - session bean puts the entity bean's ID in JMS
    messagesession bean method ( <------- start of transaction boundary or join an existing one)
    create entity bean
    send message to JMS
    // some other things you want to do
    end of method ( <--- For CMT, container will commit transaction or continue with joined transaction and commit at the end )
    So mebbe your MDB is trying to locate the entity bean before the transaction is commited? How about you try this,
    1. Put the entity bean creation in its own method, say createMyEntity() and make it return the primary key on success.
    2. Set this method's tx attribute to RequiresNew.
    3. Now in your original method, call the createMyEntity method and use the returned primary key value to create your JMS message.
    4. Make the MDB tx attribute as RequiresNew also.
    Hope this helps.
    Cheers.

  • Problem : when calling the findbyPrimaryKey(id) method

    when I call the create() method and insert into the database it works fine but when i call the findByPrimaryKey() method it doesnt return anything and gives the following error.
    Cannot find principal mapping information for data source with JNDI name jdbc/Cloudscape
    Sinet

    read this one:
    http://developer.java.sun.com/developer/onlineTraining/J2EE/Intro/jdbc.html
    Almost at the bottom you wil see your error message explained.

  • Problem with 1-to-many relationship between entity beans

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    gimbal2 wrote:
    1: The @JoinColumn on the listOfDepartments collection in Company is wrong. It should be something like this for a bidirectional relationship:
    @OneToMany(mappedBy="company") // company is the matching property name in Department
    private List <Department> listOfDepartment = new ArrayList<Department>();Note that I removed the fetch configuration; onetomany is fetched lazy by design. Saves some clutter eh.
    2: use a Set in stead of a List (hibernate doesn't like lists much in entities and will break when you create slightly more complex entity relations)
    3: don't just slap cascades on collections, especially of type ALL. Do it with care. In the many years I've been using JPA I've only had to cascade deletes in very specific situations, maybe once or twice. I never needed any of the other cascade types, they just invite sloppy code if you ask me. When working with persistence you should apply a little precision.I made all changes as you mentioned but still compID in department table shows null value...

  • Problem with 1:many relationship between entity beans.

    Hi All!
    I have two tables TMP_GROUP and TMP_EMPLOYEE with following fields:
    TMP_GROUP: ID, CAPTION, COMMENT, STATUS.
    TMP_EMPLOYEE: ID, LOGIN, GROUP_ID.
    For this tables i create two entity beans GROUP and EMPLOYEE respectively.
    The relationship looks like this
    descriptor ejb.xml:
    <ejb-relation>
                <description>description</description>
                <ejb-relation-name>employeesOfGroup</ejb-relation-name>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.GroupBean</ejb-relationship-role-name>
                    <multiplicity>One</multiplicity>
                    <relationship-role-source>
                        <ejb-name>GroupBean</ejb-name>
                    </relationship-role-source>
                    <cmr-field>
                        <cmr-field-name>employees</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                    </cmr-field>
                </ejb-relationship-role>
                <ejb-relationship-role>
                    <ejb-relationship-role-name>com.mypackage.EmployeeBean</ejb-relationship-role-name>
                    <multiplicity>Many</multiplicity>
                    <relationship-role-source>
                        <ejb-name>EmployeeBean</ejb-name>
                    </relationship-role-source>
                </ejb-relationship-role>
            </ejb-relation>
    descriptor persistent.xml:
    <table-relation>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>GroupBean</ejb-name>
                        <cmr-field>employees</cmr-field>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="NoKey">
                        <ejb-name>EmployeeBean</ejb-name>
                        <fk-column>
                             <column-name>GROUP_ID</column-name>
                             <pk-field-name>ejb_pk</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
    Now i implement business method:
    public Long addEmployee(String login, long groupId) {
              Long result;
              try {
                   EmployeeLocal employee = employeeHome.create(login);
                   GroupLocal group =
                        groupHome.findByPrimaryKey(new Long(groupId));
                   Collection employees = group.getEmployees();
                   employees.add(employee);
                   result = (Long) employee.getPrimaryKey();
              } catch (CreateException ex) {
                   result = new Long(0);
              } catch (FinderException ex) {
                   result = new Long(0);
              return result;
    When i call this method from web service, the following exception is raised:
    com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.mypackage.GroupLocalHomeImpl0.findByPrimaryKey(java.lang.Object).
    P.S.
    1) I have transaction attribute set to "Required" for all methods of all beans
    2) I have unique index for each table:
    TMP_GROUP_I1: CAPTION
    TMP_EMPLOYEE_I1: LOGIN (however i think GROUP_ID must be added here too)
    3) I tried many:many relationship with this tables and it works fine
    4) I try another implementation of addEmployee method with
    EmployeeLocal employee = employeeHome.create(login, groupId);
    without using GroupLocal cmr-field and GroupLocalHome findByPrimaryKey method, the result is same error.
    Can somebody help me with this problem?
    Thanks in advance.
    Best regards, Abramov Andrey.

    I have posted excerpts from my orion-ejb-jar.xml file in this posting: Problem mapping a 1:M relationship between two entity EJBs w/ a compound PK
    Sorry for the duplicate postings, but I was getting errors on the submission.
    April

  • Problem in using InitialContext to do a lookup of CMP EnitityBean.

    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it to do the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY, weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception is thrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafeEE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin\Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\VisualCafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\VisualCafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin\Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some other related articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "Need to specify class name in environment or system
    property, or as an applet parameter, or in an application
    resource file: java.naming.factory.initial"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

    Thanks Gene. Good solution. I could solve the problem which is explained in my another article posted just before a minute you posted this response.
    Thanks again.
    Ashok Pancharya
    "Gene Chuang" <[email protected]> wrote:
    According to your getWeblogicInitialContext(), you are putting ctxt.close() in a finally block,
    which will always get executed, and then returning ctxt. Don't think you can do any lookups with a
    closed Context.
    Gene Chuang
    Join Kiko.com!
    "Ashok Pancharya" <[email protected]> wrote in message news:[email protected]...
    Hi,
    I am running WLS 5.1 SP6 on Windows98. I am trying to lookup a CMP entiry bean from
    Java 1.3 client. I can successfully create the InitialContext but having trouble in using it todo the lookup. I get the following error:
    jndiContext is javax.naming.InitialContext@61f24(This is line is the result of println : see code)
    javax.naming.NoInitialContextException: Need to specify class name in environment or systemproperty, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.lookup(Unknown Source)
    at com.titan.cabin.Client_1.main(Client_1.java:21)
    My code of the Java 1.3 client is as follows:
    package com.titan.cabin;
    import com.titan.cabin.CabinHome;
    import com.titan.cabin.Cabin;
    import com.titan.cabin.CabinPK;
    import javax.naming.InitialContext;
    import javax.naming.Context;
    import javax.naming.NamingException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import java.util.Hashtable;
    public class Client_1 {
    public static void main(String [] args){
    try {
    InitialContext jndiContext = getWeblogicInitialContext();
    System.out.println("jndiContext is " + jndiContext);
    CabinHome home = (CabinHome)(jndiContext.lookup("CabinHome"));
    Cabin cabin_1 = home.create(1);
    System.out.println("created it!");
    cabin_1.setName("Master Suite");
    cabin_1.setDeckLevel(1);
    cabin_1.setShip(1);
    cabin_1.setBedCount(3);
    CabinPK pk = new CabinPK();
    pk.id = 1;
    System.out.println("keyed it! ="+ pk);
    Cabin cabin_2 = home.findByPrimaryKey(pk);
    System.out.println("found by key! ="+ cabin_2);
    System.out.println(cabin_2.getName());
    System.out.println(cabin_2.getDeckLevel());
    System.out.println(cabin_2.getShip());
    System.out.println(cabin_2.getBedCount());
    } catch (java.rmi.RemoteException re){re.printStackTrace();}
    catch (javax.naming.NamingException ne){ne.printStackTrace();}
    catch (javax.ejb.CreateException ce){ce.printStackTrace();}
    catch (javax.ejb.FinderException fe){fe.printStackTrace();}
    public static InitialContext getWeblogicInitialContext()
    throws javax.naming.NamingException {
    InitialContext ctx = null;
    Hashtable ht = new Hashtable();
    ht.put(Context.INITIAL_CONTEXT_FACTORY,weblogic.jndi.WLInitialContextFactory.class.getName());
    ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
    ht.put(Context.SECURITY_PRINCIPAL, "system");
    ht.put(Context.SECURITY_CREDENTIALS, new weblogic.common.T3User("system", "askpanch"));
    try {
    ctx = new InitialContext(ht);
    // Use the context in your program
    catch (NamingException e) {
    System.out.println("InitialContext could not be created");
    System.out.println("The explanation is " + e.getExplanation());
    e.printStackTrace();
    // a failure occurred
    finally {
    try {ctx.close();}
    catch (Exception e) {
    // a failure occurred
    return ctx;
    The message printed by System.out.println shows that InitialContext is created but exception isthrown when it is used by the lookup method.
    My classpath is as follows:
    CLASSPATH=C:\VisualCafeEE\Java\Lib\ERADPUBLIC.JAR;C:\VisualCafeEE\Java\Lib\servlet.jar;C:\VisualCafe
    EE\Java\Lib\server.jar;C:\VisualCafeEE\Bin\Components\templa
    >
    tes.jar;C:\VisualCafeEE\Java\Lib\javax_ejb.ZIP;C:\VisualCafeEE\Java\Lib\jndi.jar;C:\VisualCafeEE\Bin
    \Components\vcejbwl.jar;C:\VisualCafeEE\Bin\sb;C:\VisualCafe
    >
    EE\Bin\sb\classes\sb.jar;.;;C:\VisualCafeEE\Java\Lib;C:\VisualCafeEE\Java\Lib\SYMCLASS.ZIP;C:\Visual
    CafeEE\Java\Lib\CLASSES.ZIP;C:\VisualCafeEE\Java\Lib\COLLECT
    >
    IONS.ZIP;C:\VisualCafeEE\Java\Lib\ICEBROWSERBEAN.JAR;C:\VisualCafeEE\Java\Lib\SYMTOOLS.JAR;C:\Visual
    CafeEE\JFC\SWINGALL.JAR;C:\VisualCafeEE\Bin\Components\SFC.J
    >
    AR;C:\VisualCafeEE\Bin\Components\SYMBEANS.JAR;C:\VisualCafeEE\Java\Lib\DBAW.ZIP;C:\VisualCafeEE\Bin
    \Components\DBAW_AWT.JAR;C:\VisualCafeEE\Bin\Components\Data
    >
    bind.JAR;C:\VisualCafeEE\Java\Lib\ERADTOOLS.JAR;;C:\IBMVJava\eab\runtime30;C:\IBMVJava\eab\runtime20
    ;;.;c:\Weblogic\classes;c:\weblogic\lib\weblogicaux.jar
    Any help to solove this problem from anybody is greatly appreciated. I am including some otherrelated articles in this newsgroup for your ready reference(see below).
    Thanks a lot,
    Ashok Pancharya
    Email: [email protected]
    Sounds like your WL config is a bit different, perhaps a classpath issue or
    a missing .properties file or a different command line. For whatever
    reason, the factory does not know what class is supposed to be used as the
    initial context.
    Peace.
    Cameron Purdy
    [email protected]
    http://www.tangosol.com
    WebLogic Consulting Available
    "Chris Solar" <[email protected]> wrote in message
    news:[email protected]...
    Hi-
    I'm running WLS 5.1 on NT 4.0 (SP6).
    For some reason, I'm unable to use the default
    constructor to get an initial context. That is,
    if I try:
    InitialContext ctx = new InitialContext();
    I get a NoInitialContextException, as in:
    "Need to specify class name in environment or system
    property, or as an applet parameter, or in an application
    resource file: java.naming.factory.initial"
    This does not happen if I pass in a HashTable or Properties
    object containing a value for the initial context factory
    (even if it's just weblogic.jndi.WLInitialContextFactory).
    Colleagues of mine seem to be able to use
    the defaut constructor without any problems.
    What am I missing?
    -Chris.

  • Comp. Primary key class-field mapping to DB columns problem.(EJB 2.0 CMP)

    Hi!
    I have deal with EJB 2.0 CMP bean.
    I have a composite PK so use the java class to store it. And there is a corresponding field in the Entity Bean with its primary key class type.
    The problem is: when deployment tool creates sql query for the findByPrimaryKey(PKClass ck)
    where ck is an object with 3 fielde : a_id, b_id, c_id.
    it says:
    <sql>SELECT "ck" FROM "MyTable" WHERE "ck" = ? </sql>
    And it means by the "ck" simple a column in DB but NOT the composite key which has to be splited into 3 different fields. So the container can't do the proper mapping.
    Does anyone know solutions?

    I was wrong about primary key class fields, take a look at Ejb2.0 Specification (10.8.2):
    The primary key class must be public, and must have a public constructor with no parameters.
    All fields in the primary key class must be declared as public.
    The names of the fields in the primary key class must be a subset of the names of the container-managed
    fields. (This allows the container to extract the primary key fields from an instance�s container-managed
    fields, and vice versa.)
    Right now I'm using BMP and I don't have this problems. Primary keys, calculated fields and types not supported by the DB can be easily achieved. But I understand your interest on CMP, is clearly evolving!

  • Problems accessing fields in a CMP entity bean from a session bean

    Hello everybody,
    I'm getting the next problem: when I try to access a field in a CMP entity bean that I have instantiated from a session bean (trhoug entitybean.getNameOfField), I get the error "the entity bean does not exist in the database".
    This entity bean is accessing a table in an external database (not the DB of the WAS), but I know that it's getting the correct data from the table, since  I check the entitybean.size() and the entitybean.findByPrimaryKey(), and I get the right information. For some reason, the only thing that it doesn't work in the entity bean are the getter/setter methods (I created them automatically after having created the entity fields).
    I access the entity bean through its local interface...
    I know it's really difficult to give an answer with so few details, but... does anybody think I forgot something important to configure??
    Thank very much in advance!!
    Isidro

    getter and setter methods for cmp-fields are abstract.
    getter and setter methods for cmr-fields are abstract.
    "John Lee" <[email protected]> wrote:
    >
    Hi:
    Which method in a CMP Entity bean should be abstract? just only SetXXX
    and
    GetXXX?
    Thanks!
    John Lee

  • What is the problem?

    I want to deploy a CMP Entity Bean in weblogic6.1SP2,but I meet an error,what should I do to solve the problem?
    the error code:
    <2003-4-7 ~{OBNg~}02~{J1~}27~{7V~}24~{Ck~}> <Error> <J2EE> <Error deploying application SVC:
    Unable to deploy EJB: CMPSvc from SVC.jar:
    The Container-Managed Persistence Entity EJB failed while creating its SQL Type
    Map. The error was:
    Io ~{Rl3#~}: Connection reset by peer: socket write error
    and my original code:
    SVC.java(remote interface)
    package CMPEntityBean;
    import javax.ejb.*;
    import java.rmi.RemoteException;
    public interface SVC extends EJBObject
         public java.lang.String getSvcID() throws RemoteException;
         public java.lang.String getSvcName() throws RemoteException;
         public void setSvcID(java.lang.String svcID) throws RemoteException;
         public void setSvcName(java.lang.String svcName) throws RemoteException;
    SVCHome.java (home interface file)
    package CMPEntityBean;
    import javax.ejb.*;
    import java.rmi.RemoteException;
    import java.util.Collection;
    public interface SVCHome extends EJBHome
    public SVC create(java.lang.String svcID,java.lang.String svcName) throws CreateException,RemoteException;
    public SVC findByPrimaryKey(CMPEntityBean.SVCPK key) throws FinderException,RemoteException;
    public Collection findBySvcName(java.lang.String svcName) throws FinderException,RemoteException;
    SVCBean.java (Enterprise Bean file)
    package CMPEntityBean;
    import javax.ejb.*;
    public abstract class SVCBean implements EntityBean
         protected EntityContext ctx;
         public abstract java.lang.String getSvcID();
         public abstract java.lang.String getSvcName();
         public abstract void setSvcID(java.lang.String svcID);
         public abstract void setSvcName(java.lang.String svcName);
         public void ejbActivate(){}
         public void ejbRemove(){}
         public void ejbPassivate(){}
         public void ejbLoad(){}
         public void ejbStore(){}
         public void setEntityContext(EntityContext ctx)
         this.ctx = ctx;
         public void unsetEntityContext()
         this.ctx = null;
         public void ejbPostCreate(String svcID,String svcName){}
         public SVCPK ejbCreate(String svcID,String svcName)
         setSvcID(svcID);
         setSvcName(svcName);
         return new SVCPK(svcID);
    ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>CMPSvc</ejb-name>
    <home>CMPEntityBean.SVCHome</home>
    <remote>CMPEntityBean.SVC</remote>
    <ejb-class>CMPEntityBean.SVCBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>CMPEntityBean.SVCPK</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>SVCBean</abstract-schema-name>
    <cmp-field>
    <field-name>svcID</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>svcName</field-name>
    </cmp-field>
    <!--prim-key-class>svcID</prim-key-class-->
    <query>
    <query-method>
    <method-name>findBySvcName</method-name>
    <method-params>
    <method-param>java.lang.String</method-param>
    </method-params>
    </query-method>
         <!--result-type-mapping>Local</result-type-mapping-->
    <ejb-ql>
    SELECT OBJECT(a) FROM SVCBean a WHERE svcName = ?1
    </ejb-ql>
    </query>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>CMPSvc</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    </ejb-jar>
    weblogic-ejb-jar.xml
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN" "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd" >
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>CMPSvc</ejb-name>
    <entity-descriptor>
    <entity-cache>
         <max-beans-in-cache>1000</max-beans-in-cache>
    </entity-cache>
    <persistence>
         <persistence-type>
         <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
         <type-version>6.0</type-version>
         <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
         </persistence-type>
         <persistence-use>
         <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
         <type-version>6.0</type-version>
         </persistence-use>
    </persistence>
    </entity-descriptor>
    <jndi-name>cmpsvc</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    weblogic-cmp-rdbms-jar.xml
    <!DOCTYPE weblogic-rdbms-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB RDBMS Persistence//EN' 'http://www.bea.com/servers/wls600/dtd/weblogic-rdbms-persistence.dtd'>
    <weblogic-rdbms-jar>
    <weblogic-rdbms-bean>
    <ejb-name>CMPSvc</ejb-name>
    <data-source-name>ucisOra</data-source-name>
    <table-name>TAB_SVC</table-name>
    <field-map>
    <cmp-field>svcName</cmp-field>
    <dbms-column>svcname</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>svcID</cmp-field>
    <dbms-column>svcid</dbms-column>
    </field-map>
    </weblogic-rdbms-bean>
    </weblogic-rdbms-jar>
    thanks a lot!

    Try this
    SELECT OBJECT(a) FROM SVCBean a WHERE a.svcName = ?1

  • Problem in compilation of EJBHome object

    hi
    I have created a remote interface,HOmeinterface ,a primary key class and a bean.
    The package structure is as follows:
    sampleEJB->remote interface
    sampleEJB->Home interface
    a similar directory structure for both bean as welas primary key class files.
    Now the actual problem,
    when I compile the Home inter face it gives an error stating that the remotr object cannot be found.
    I checked the package structure and found everything to be proper
    kindly help mecode of home interface:
    package sampleEJB;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    import javax.ejb.FinderException;
    public interface CabinHomeRemote extends javax.ejb.EJBHome {
    public CabinRemote create(Integer id)
    throws CreateException, RemoteException;
    public CabinRemote findByPrimaryKey(Integer pk)
    throws FinderException, RemoteException;
    Error thrown when compiling :
    C:\Data\sampleEJB>javac CabinHomeRemote.java
    CabinHomeRemote.java:9: cannot resolve symbol
    symbol : class CabinRemote
    location: interface sampleEJB.CabinHomeRemote
    public CabinRemote create(Integer id)
    ^
    CabinHomeRemote.java:12: cannot resolve symbol
    symbol : class CabinRemote
    location: interface sampleEJB.CabinHomeRemote
    public CabinRemote findByPrimaryKey(Integer pk)
    ^
    2 errors
    kindly help me . I am confounded totally
    thank you

    but as u said there is some problem in the packaage
    structure.
    I tried changing the name of the package and trird
    .but still could not get
    What else can i change the program.
    This was working well , and all of a sudden it has
    starte to throw these errors.How do your errors come all of a sudden? No forewarning!
    Are you using an IDE? like Eclipse. It will solve your compilation problem :)

  • Problem in placing the EJB queries

    Hi all,
    I am working on the migration of an application from J2EE to SAP WAS.
    The original application contains some EJB queries present in the file sun-j2ee-ri.xml.
    Entery for one of the query is given below:
    <ejb20-cmp>
    <sql-statement>
    <operation>storeRow</operation>
    <sql>UPDATE "UserEJBTable" SET "password" = ? WHERE "userName" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>findByPrimaryKey</operation>
    <sql>SELECT "userName" FROM "UserEJBTable" WHERE "userName" = ? </sql>
    </sql-statement>
    </ejb20-cmp>
    I cannot understand where(in which file) to make entry for this query.
    Please help me out with this problem.

    Hi Neethu ..
        can u create one more finderMethod in ur EJB?.
    then that will be dislayed in the persistent.xml files.
    u can select that findermethod from Query subtab , and write ur own queries there..
                      not sure , u can overwrite the standard  finderMethod..
                                      Regards
                                      Kishor Gopinatha

  • A very Strange Problem!!!help me!!

    i encounter a very strange problem, in EJB
    i write two EJB, one Stateless Session called A, and one Entity called B.
    i want to call B's findByPrimaryKey method in one A's Business, but failed!!!
    but when i remove the statement that performed the findByPrimaryKey method to A's setSessionContext method, It's Success!!!!!
    what the Problem, i am useing the Borland 's AppServer.
    who can help

    how u create the entity bean B from A?
    using proper lookup?
    can u try by write a small function inside bean A
    that contain proper lookup to Bean B...
    then try to call finbyPrimaryKey...
    now tell me is it working?
    or else can u give code or clear idea..
    if i can help u ,,,, sure i will
    do mail me
    [email protected]

  • Transaction problem in ejb

    Hi
    I have a problem related to CMP entity beans.
    I am using Oracle 9i and weblogic 6.1
    Here is the description of the problem.
    The transaction attribute of all the beans is set to 'Required'.
    I have a PersonBean (CMP) in Person.jar mapping to Person table along with other
    beans.
    I have a MemberBean(CMP) in Member.jar file mapping to Member table along with
    many other beans.
    There is a one to many relation ship between person and member tables in Oracle
    9i database :
    Id in the person table is the P_Key and Person_Id in Member table is the related
    foreign key.
    No relationship was made between Person and Member beans as there were in two
    different jar files with different deployment descriptors.
    I have a stateless session bean PersonService bean.
    There is a method in PersonService bean called createPerson(String name);
    This method creates Person in the database using Person p = PersonHome.create(),
    long personId = p.getId()..returns the primary key of the person.
    PersonService calls createMember(long personId) now.
    which will try to create a Member record in the database using the personId.
    Now the Member bean fails to create and the transaction is rolled back with a
    foreign_key violation exception.
    because it cannot locate the Person EJB Primary key entry in the underlying table.
    But the EJB cache is still inserted properly with Person EJB (findByPrimaryKey
    works).
    I feel that Member bean is not able to participate in the same transaction of
    the Person bean inspite of keeping the transaction attribute to 'Required'.
    When I keep the transaction of Person bean to 'RequiresNew', then the transation
    of createPerson is getting committed and Member is starting a New transaction
    and it gets created.
    But I donot want like this.
    I want all the beans to be participating in the same transaction.
    According to Oracle / Weblogic documentation the default database isolation mode
    Read_Committed should allow participants in transaction to see uncommitted data
    while participants outside the transaction see only committed data. I have tried
    other dataabase isolation modes (such as Read_Uncommitted, "Serializable") these
    appear to either create other problems or not have an affect.
    Any solution to this problem is highly appreciated.
    Thanks
    Lavanya

    Previously our code was running on Weblogic where
    methodA() -> Transaction Attribute -> Supports
    methodB() -> Transaction Attribute -> Required
    But in JBOSS in order to run the same thing we have to do
    methodA() -> Transaction Attribute -> Required
    methodB() -> Transaction Attribute -> Required
    Any Pointers??

  • MySQL & Sun ONE studio problem

    hello all,
    It seemed like I've got the data source & database driver stuff setup to work with MySQL database in Sun ONE studio. However, when I tried to run the helloworld_TestApp (CMP App), I've got the SQL syntax error. I tried to look at the sun-j2ee-ri.xml, and it looked just fine to me.. please help.
    Here is the XML descriptor
    <?xml version="1.0" encoding="UTF-8"?>
    <j2ee-ri-specific-information>
    <server-name></server-name>
    <rolemapping/>
    <web>
    <display-name>helloworld_TestApp</display-name>
    <servlet>
    <servlet-name>dispatch</servlet-name>
    </servlet>
    <servlet>
    <servlet-name>error</servlet-name>
    </servlet>
    <servlet>
    <servlet-name>viewer</servlet-name>
    </servlet>
    <context-root>helloworld_TestApp</context-root>
    <ejb-ref>
    <ejb-ref-name>ejb/TestedEJB</ejb-ref-name>
    <jndi-name>helloworld</jndi-name>
    </ejb-ref>
    </web>
    <enterprise-beans>
    <unique-id>1</unique-id>
    <ejb>
    <ejb-name>helloworld</ejb-name>
    <jndi-name>helloworld</jndi-name>
    <ejb20-cmp>
    <sql-statement>
    <operation>loadRow</operation>
    <sql>SELECT "lastname" FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>storeRow</operation>
    <sql>UPDATE "helloworld" SET "lastname" = ? WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>deleteRow</operation>
    <sql>DELETE FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>deleteTable</operation>
    <sql>DROP TABLE "helloworld"</sql>
    </sql-statement>
    <sql-statement>
    <operation>findByPrimaryKey</operation>
    <sql>SELECT "firstname" FROM "helloworld" WHERE "firstname" = ? </sql>
    </sql-statement>
    <sql-statement>
    <operation>createRow</operation>
    <sql>INSERT INTO "helloworld" ( "firstname" , "lastname" ) VALUES ( ? , ? )</sql>
    </sql-statement>
    <sql-statement>
    <operation>createTable</operation>
    <sql>CREATE TABLE "helloworld" ("firstname" VARCHAR(255) NOT NULL , "lastname" VARCHAR(255), CONSTRAINT "pk_helloworl" PRIMARY KEY ("firstname") )</sql>
    </sql-statement>
    <create-table-deploy>true</create-table-deploy>
    <delete-table-undeploy>false</delete-table-undeploy>
    </ejb20-cmp>
    <principal>
    <name></name>
    </principal>
    <ior-security-config>
    <transport-config>
    <integrity>supported</integrity>
    <confidentiality>supported</confidentiality>
    <establish-trust-in-target>supported</establish-trust-in-target>
    <establish-trust-in-client>supported</establish-trust-in-client>
    </transport-config>
    <as-context>
    <auth-method>username_password</auth-method>
    <realm>default</realm>
    <required>true</required>
    </as-context>
    <sas-context>
    <caller-propagation>supported</caller-propagation>
    </sas-context>
    </ior-security-config>
    </ejb>
    <cmpresource>
    <ds-jndi-name>jdbc/MySQL</ds-jndi-name>
    <default-resource-principal>
    <name>root</name>
    <password>root</password>
    </default-resource-principal>
    </cmpresource>
    </enterprise-beans>
    </j2ee-ri-specific-information>
    And here is the error message:
    The exception java.rmi.ServerException was thrown when invoking findByPrimaryKey with parameters:
    thinh
    Following is the stack trace:
    java.rmi.ServerException: RemoteException occurred in server thread; nested exception is: java.rmi.RemoteException: nested exception is: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"helloworld" WHERE "firstname" = 'thinh'' at line 1; nested exception is: java.sql.SQLException: Syntax error or access violation: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '"helloworld" WHERE "firstname" = 'thinh'' at line 1 at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.wrapException(Util.java:345) at javax.rmi.CORBA.Util.wrapException(Util.java:277) at ..
    ...more and more..

    Where are you running your application? I assume you
    are running your application on RI. Are you running
    on RI or S1AS?I am running my application on R1, is there a problem with it? can the S1AS solve the problem?
    Thanks & regards,
    Tim

  • Problem in Many-to-Many Associations (JBO-27014 error)

    I am facing a problem during insertion in an Intersection table.
    I have 3 tables Customer, Accounts and Customer_Account. In order to implement the Many to Many relationship between Customer and Accounts, I created an intersection table Customer_Account.
    Table Structure
    CUSTOMER
    Cust_id NUMBER NOT NULL PK
    Name VARCHAR2(50) NOT NULL
    ACCOUNT
    Account_Id NUMBER NOT NULL PK,
    Account_number NOT NULL,
    Sort_Code NUMBER NOT NULL,
    Account_Type VARCHAR2(10) NOT NULL
    CUSTOMER_ACCOUNT
    Cust_Id NUMBER NOT NULL,
    Account_Id NUMBER NOT NULL
    I created an Association CustAcctAsso between Customer and Account with Customer_Account as intersection entity. Then created a viewlink CustAcctViewLink with CustomerView as Source entity, AccountView as Destination entity and selected the CustAcctAsso as association.
    I included this in the application module using the following steps
    Selected AccountView via CustAcctViewLink in the Available view pane and selected CustomerView in Data model pane. Clicked > to add AccountView via CustAcctViewLink as a restricted view.
    Also added CustomerView via CustAcctViewLink as a restricted view.
    When I tried to insert data through the second restricted view I am getting an JBO 27014 Attribute Sort Code in Account is required.
    It would be very helpful if someone gives me a solution quickly.
    Thanks
    Renuka

    Thanks, now I am able to insert data into CUSTOMER and ACCOUNT table, but not in the intersection table.
    It seems that we cannot do any insertion into the intersection table. Please advice me, this is urgent.OK here's what you need to do to insert a new row in both ACCOUNT and INTERSECTION tables.
    1. Create a new viewobject with a join of INTERSECTION and ACCOUNT tables such that both are updateable but ACCOUNT is reference entity.
    -- This is assuming you want to insert a new account when you insert a new account id in the intersection table otherwise, you can make ACCOUNT entity readonly as well.
    2. Create a viewlink between Customer viewobject and this NewViewObject (1-* ViewLink).
    3. If the assumption in step 1 is NOT to update/insert new Accounts form this VO, then you're done. Add the new viewobject usage in your application module and you should be able to use it to edit/insert intersection details.
    Otherwise -
    Set the Updateable flag on AccountID (from the Account entity usage in the NewViewObject) to "never" udpateable.
    Set the Updateable flag on Other attributes from the Account entity usage in the NewViewObject to udpateable-while-new or always as desired.
    4. Select to generate EntityDefImpl subclass for Account table and override the protected method createInstance as below:
      protected EntityImpl createInstance(DBTransaction txn, AttributeList al)
        // TODO:  Override this oracle.jbo.server.EntityDefImpl method
        return super.createInstance(txn, al);
      }5. Select to generate a ViewRowImpl subclass with accessors for this NewViewObject
    6. Add the following logic in setAccountID() method (assuming AccountId attribute is editable and from Intersection entity)
    (Note you'll also have anothe attribute AccountId1 from Account entity which should be readonly as marked in step 3.)
    //get the current intersection entity.
    IntersectionImpl intersection = (IntersectionImpl)getEntity(1);
    setAttributeInternal(ACCOUNTID1, value);
    //if it is same as I added and is not the same as new one
    //framework may assign a new intersection entity based on FK.
    IntersectionImpl newIntersection = (IntersectionImpl)getEntity(1);
    IntersectionDefImpl intersectiondef = (IntersectionDefImpl)IntersectionImpl.getDefinitionObject();
    IntersectionEnrollmentImpl myVO = ((IntersectionEnrollmentImpl)getViewObject());
    DBTransaction dbtxn = myVO.getDBTransaction();
    //see if a intersection exists with this FK
    intersection = (IntersectionImpl)intersectiondef.findByPrimaryKey(dbtxn, IntersectionImpl.createPrimaryKey(value));
    //if this viewrow created a new intersection earlier which is different from
    //the current intersection entity, remove the old one as I created it.
    if ((intersectionAdded != null) && (intersection != intersectionAdded || newIntersection != intersectionAdded))
      if (intersection == null)
        //if I added this intersection as new, reuse-it.
        intersection = intersectionAdded;
        intersection.setIntersectionid(value);
      else
        //if I added this intersection as new, remove it.
        System.out.println(">>>>removing :"+intersectionAdded.getAttribute(0));
        intersectionAdded.remove();
        intersectionAdded = null;
    if (intersection == null)
      //if new intersection is null = no intersection exists with this key, then create a new one.
      intersection = (IntersectionImpl)intersectiondef.createInstance(dbtxn, new AttributeListImpl());
      intersection.setIntersectionid(value);
      intersectionAdded = intersection;
      setEntity(1, intersection);
      myVO.notifyRowUpdated(findRowSetForRow(this), new ViewRowImpl[]{this}, new int[]{2,3});
    else if (intersection != newIntersection)
      //otherwise, create a set the new intersection entity as my intersection entity reference
      setEntity(1, intersection);
      myVO.notifyRowUpdated(findRowSetForRow(this), new ViewRowImpl[]{this}, new int[]{2,3});
    }Now when you insert a new row in this NewViewObject, you can either enter a new Account or refer to an existing Account.
    The setAccountId() method will automatically bring the Account details for existing accounts or create a new Account entity as in the above logic.

Maybe you are looking for