Putting sql code in a ejb cmp method

hi i was wondering if there are any performance implications with creating a method in a cmp bean that performs an sql query as opposed to putting the query in the ejb deployment file. the reason i did this is that the ejb is quering a different table other than the one its mapped to. e.g. my cmp ejb is mapped to a table called Users (hence the bean is UserBean), and its querying a table called Address . What would be the best practice? Should I create an Address bean? The method in the UserBean e.g. getAddressForUser(String user_id) will be called quite frequently. What is the recommended best practice in this situation?
Thanks for your input.
Reed

hi i was wondering if there are any performance
implications with creating a method in a cmp bean
that performs an sql query as opposed to putting the
query in the ejb deployment file.You mean deployment descriptor ? You cannot write any SQL there.
Only EJB-QL.
the reason i did
this is that the ejb is quering a different table
other than the one its mapped to. e.g. my cmp ejb is
mapped to a table called Users (hence the bean is
UserBean), and its querying a table called Address .
What would be the best practice? Should I create an
n Address bean? The method in the UserBean e.g.
getAddressForUser(String user_id) will be called
quite frequently. What is the recommended best
practice in this situation?Create Address bean and use EJB-QL to get address for a user.
If you use CMP beans then you should have a bean for each table.
You can even use some nice tool (Middlegen) to generate entity beans.
But do use SQL for dynamic , complex database searches and bulk updates.
best regards,
Maris Orbidans

Similar Messages

  • How to view the sql queries generated by EJB (CMP)

    Hello,
    I'm using Oracle9iAS (9.0.2.1.0) Containers for J2EE (build 020827.1652) & Oracle 8.1.7 database.
    I have a CMP that has about 400 fields and the corrsoponding table has about 800 fields. I'm able to call create and add a row in database.
    Now when I call update method to set the remaining fields of this row (I get the proper instance by calling findByPrimaryKey()) I'm getting an exception ORA-00957 duplicate column name.
    I'm using reflection to set all the fields by passing my update method a HashMap and setting those fields that this HashMap contains. And as HashMap cannot contain duplicate keys the possiblility of having duplicates is eliminated.
    But why am I getting ORA-00957 duplicate column name.
    Is there a way I can configure somehow to view what sql query is being generated by the OC4j container when its firing this query to update the database table.
    Any help will be greatly appriciated.
    Vipin.

    Install IronTrack SQL as described in the following link
    http://www.irongrid.com/documentation/irontracksql/install.html#install_oracle9iAS

  • How to review implication of database character set change on PL/SQL code?

    Hi,
    We are converting WE8ISO8859P1 oracle db characterset to AL32UTF8. Before conversion, i want to check implication on PL/SQL code for byte based SQL functions.
    What all points to consider while checking implications on PL/SQL code?
    I could find 3 methods on google surfing, SUBSTRB, LENGTHB, INSTRB. What do I check if these methods are used in PL/SQL code?
    What do we check if SUBSTR and LENGTH functions are being used in PL/SQl code?
    What all other methods should I check?
    What do I check in PL/SQL if varchar and char type declarations exist in code?
    How do i check implication of database characterset change to AL32UTF8 for byte bases SQL function.
    Thanks in Advance.
    Regards,
    Rashmi

    There is no quick answer.  Generally, the problem with PL/SQL code is that once you migrate from a single-byte character set (like WE8ISO8859P1) to a multibyte character set (like AL32UTF8), you can no longer assume that one character is one byte. Traditionally, column and PL/SQL variable lengths are expressed in bytes. Therefore, the same string of Western European accented letters may no longer fit into a column or variable after migration, as it may now be longer than the old limit (2 bytes per accented letter compared to 1 byte previously). Depending on how you dealt with column lengths during the migration, for example, if you migrated them to character length semantics, and depending on how relevant columns were declared (%TYPE vs explicit size), you may need to adjust maximum lengths of variables to accommodate longer strings.
    The use of SUBSTR, INSTR, and LENGTH and their byte equivalents needs to be reviewed. You need to understand what the functions are used for. If the SUBSTR function is used to truncate a string to a maximum length of a variable, you may need to change it to SUBSTRB, if the variable's length constraint is still declared in bytes.  However, if the variable's maximum length is now expressed in characters, SUBSTR needs to be used.  However, if SUBSTR is used to extract a functional part of a string (e.g. during parsing), possibly based on result from INSTR, then you should use SUBSTR and INSTR independently of the database character set -- characters matter here, not bytes. On the other hand, if SUBSTR is used to extract a field in a SQL*Loader-like fixed-format input file (e.g. read with UTL_FILE), you may need to standardize on SUBSTRB to make sure that fields are extracted correctly based on defined byte boundaries.
    As you see, there is universal recipe on handling these functions. Their use needs to be reviewed and understood and it should be decided if they are fine as-is or if they need to be replaced with other forms.
    Thanks,
    Sergiusz

  • JBuilder Question -  Where do i put the code?

    I am building a jList using the designer in
    Jbuilder. In what event procedure do i put the
    code that assigns an array and so on?
    thanks for any help
    maggie evans

    Typically you'll code the initial population of UI components in the jbInit method. If you want to dynamically populate the list as a result of a selectable UI component being clicked then put the code in the action performed method for the 'clicked' component.

  • Javax.ejb.EJBException: Method is not a known CMP field accessor...

    Hi !
    I have a little problem. When I deploy my jar file, I have the next message :
    "javax.ejb.EJBException: Method is not a known CMP field accessor, CMR field accessor, or ejbSelect method: methodName=compareTo"
    Is there someone to tell me why ? ^_^
    I didn't put the source code in this topic, not to pollute it, but if you need it, tell me ;)
    Thx for your help.

    Hi Spidey !
    Thx for you help but... Giving my method doesn't require the use of EJBQL, I don't think I have to define it in my deployment descriptor (this is not a query)...
    I give you an idea of my (experimental ^_^) source code :
    public class CountryBean implements EntityBean{
    public int compareTo(Country c){
    SOP("COMPARE TO");
    return 0;
    public class MySession implements SessionBean{
    public int doIt(){
    MyComparator comparator = new MyComparator();
    return comparator.compare(country1, country2);
    public class MyComparator implements Comparator{
    public int compare(Object o1, Object o2){
    return compare((Country)o1, (Country)o2);
    public int compare(Country c1, Country c2){
    SOP("COMPARE");
    return c1.compareTo(c2);
    When I call doIt(), the message "COMPARE" is written and just after, there's this message (the message "COMPARE TO" is never written):
    "11:29:44,204 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
    javax.ejb.EJBException: Method is not a known CMP field accessor, CMR field accessor, or ejbSelect method: methodName=compareTo
    at org.jboss.ejb.plugins.cmp.bridge.EntityBridgeInvocationHandler.invoke(EntityBridgeInvocationHandler.java:110)
    at org.jboss.proxy.compiler.Runtime.invoke(Runtime.java:59)
    at CountryBean$Proxy.compareTo(<generated>)"
    I hope this is clear ^__^
    Thx for helping me ;)

  • If DB Column java.sql.Types=CHAR = Workshop autogen EJB CMP Filed=Boolean

    Hi everybody<br>
    <p class="MsoNormal"><span lang="EN-US">When a user automatically
    creates/generates an Entity Bean via BEA Workshop EJB Project option: ‘<b>new
    Entity bean from database table</b>’ and DB Table Column is of type <b>CHAR</b>,
    Workshop creates a <b>@ejbgen:cmp-field</b> of Java type <b>Boolean</b>, NOT of
    <b>Character</b>!</span></p>
    <p class="MsoNormal"><span lang="EN-US">I completely agree that the developer
    must be acquainted with the Data Base and DB Tables as well and he can manually
    correct </span><span lang="EN-US" style="font-size: 10.0pt">SET & GET</span><span lang="EN-US">
    Boolean to Character in EJB source code view or he’ll receive an error if he
    tries to <b>set<i>FieldName</i></b><i>(String/Character) </i>in <b>ejb</b>
    methods.</span></p>
    <p class="MsoNormal"><span lang="EN-US">But suppose that a developer has
    urgently received an order to build an EJB Project for a thousand of DB Tables
    and he hasn’t been acquainted with all of them. He has created the EJBs via <b>
    ‘new -> Entity bean from database table’. </b>He has created some EJB Finders,
    for example a finder:  <b>ejbgen:finder Collection find<i>All</i>()</b>.
    (<i>Suppose he hasn’t used <b>group-name</b> finder property</i>)</span></p>
    <p class="MsoNormal"><span lang="EN-US">He has invoked <b>find<i>All</i>()</b>
    method and depends on the JDBC Driver used, he will receive an </span>
    <span lang="EN-US" style="font-size: 10.0pt">ERROR</span><span lang="EN-US">,
    printed within the Server start console <b>at least</b> OR the result after <b>
    get<i>FieldName</i></b>() will be '<b>false</b>', not an expected <i><b>char</b></i>
    symbol.</span></p>
    <p class="MsoNormal"><b><span lang="EN-US">Anxious conclusion: </span></b></p>
    <p class="MsoNormal"><span lang="EN-US">If<b>  </b>DB Column<b>  java.sql.Types
    = </b></span><span lang="EN-US" style="font-size: 10.0pt"><b>CHAR</b>    </span><span lang="EN-US">then</span><span lang="EN-US" style="font-size: 10.0pt">  
    </span><span lang="EN-US"><b>getJavaObjectType = Boolean </b> then corresponding
    EJB CMP Filed  will always be   <b>Boolean</b>  in BEA Workshop !</span></p>
    <p class="MsoNormal"><i><span lang="EN-US">Following description considers the
    </span><span lang="EN-US" style="font-size: 11.0pt">PROBLEM</span><span lang="EN-US">:</span></i></p>
    <p class="MsoNormal"><span lang="EN-US">Class<b>
    weblogic.jdbc.utils.schema.Column </b>from<b> weblogic.jar </b>and its method<b>
    String getJavaType() </b>has a <b>switch(getType())</b> with <b>case:</b></span></p>
    <p class="MsoNormal"><span lang="en-us"><b> if(this.getSize() == 1)<br>
        return "boolean"; <br>
    else<br>
        return "String";</b></span></p>
    <p class="MsoNormal"><span lang="en-us">and </span>
    <span lang="EN-US" style="font-size: 12.0pt; font-family: Times New Roman">
    another </span><span lang="en-us"> method <b>String getJavaObjectType() </b>
    {</span></p>
    <p class="MsoNormal"><b><span lang="en-us">String s = this.getJavaType();</span></b></p>
    <p class="MsoNormal"><b><span lang="en-us">...</span></b></p>
    <p class="MsoNormal"><b><span lang="en-us">    
    if(s.equals("boolean"))<br>
            return "Boolean";</span></b></p>
    <p class="MsoNormal"><span lang="en-us"><b>    
    if(s.equals("char"))<br>
            return "Character";</b></span></p>
    <p class="MsoNormal"><span lang="en-us"><b>... }<br>
    </b>but according to </span><span lang="EN-US"><b>switch(getType())</b> which
    has NOT  a<b> 'case' return char</b>, </span><span lang="en-us"><b>
    'Character' </b>will never be returned, so:</span></p>
    <p class="MsoNormal"><span lang="EN-US"><b>@ejbgen:cmp-field</b> of Java type <b>
    Character </b></span><span lang="en-us">will never be generated by Workshop.</span></p>
    <p class="MsoNormal" align="left"><span lang="EN-US">More often than not  I’ve
    ran into this little but disturbing problem, so I’ve corrected <b>
    weblogic.jdbc.utils.schema.Column.getJavaType switch case </b>as:</span></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">       
    case 1:     // '\001'  //</span><span lang="EN-US" style="font-size: 10.0pt">CHAR</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">
                if(this.getSize() == 1)</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">          
         return "char";  </span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">private
    static final boolean </span><span lang="EN-US" style="font-size: 10.0pt">
    CHAR_TO_BOOLEAN</span><span lang="EN-US"> = false;     </span></b><span lang="EN-US">//as
    a field variable</span></p>
    <p class="MsoNormal" style="text-indent:35.4pt"><b><span lang="EN-US">…</span></b></p>
    <p class="MsoNormal" style="text-indent:35.4pt"> </p>
    <p class="MsoNormal" style="text-align:justify"><span lang="EN-US">Using this
    correction and precompiled class I’ve built and tested a lot of projects w/o
    problems so far.</span></p>
    <p>Best regards: George Moykin<p>
    P.S. I appologize to site Admins for posting the same topic in EJB forum, but it refers to EJBs too.

    Hi,<br>
    In your database, we have some columns of CHAR type and this is the decision of our DB architects. I understand the case ‘male’ or ‘female’, true or false, either; but only if I must choose between 2 variants. Our DB columns contain char symbols such as ‘:’, ‘;’,’-’ etc. and for some inner purposes our architects decided DB columns to be of type CHAR, not VARCHAR. In this case, the Workshop transformation ‘CHAR to BOOLEAN’ doesn’t do useful work. So, I’ve decided to modify some weblogic.jar classes (as described) and now I’m able to generate Entity EJB from DBMS Tables w/o manual intervention.<br>
    Best Regards

  • How to read the method and put that code in 1 internal table

    Hi,
    Actually in the normal ABAP, if we want to read the report,  then we will write read report statement.
    If we want to read method then this statement will not work.
    So, to read the method and put that code in 1 internal table , which statement we need to write?
    Regards,
    Radhika

    Hi Naimesh,
    Thanks for your reply.
    As, i am not aware of ABAP Objects i am having some issues:
    Actually that is working for some methods in some classes.
    Here 1 issue is there:
    In se24 1 method is there in 1 class.
    Even by using that FM in SE37 i am able to get the program name by giving class and method name,
    but while using that FM in the program i am not able to get that program name.
    so, i am unable to read the source code of the program?
    1 example here:
    Class name is CL_GUI_FRONTEND_SERVICES.
    in this class, methods like FILE_EXIST , FILE_GET_SIZE, etc are there.
    By giving the class name and method name i am able to get the program name also,
    but while using that FM in the program i am not able to get that program name.
    so, i am unable to read the source code of the program?
    Here is my code:
    REPORT  Z16059_SCAN_METHOD.
    DATA: BEGIN OF I_PROGRAM OCCURS 0,
          LINE(256) TYPE C,
          END OF I_PROGRAM.
    DATA METHOD TYPE PROGRAM.
    DATA: BEGIN OF I_STRUCTURE,
          CLS_NAME(30) TYPE C,
          METH_NAME(61) TYPE C,
          END OF I_STRUCTURE.
    I_STRUCTURE-CLS_NAME = 'CL_GUI_FRONTEND_SERVICES'.
    I_STRUCTURE-METH_NAME = 'CL_GUI_FRONTEND_SERVICES-FILE_EXIST'.
    CALL FUNCTION 'SEO_METHOD_GET_INCLUDE_BY_NAME'
      EXPORTING
      MTDKEY             =  I_STRUCTURE
    IMPORTING
       PROGNAME          = METHOD
    EXCEPTIONS
       INTERNALMETHOD_NOT_EXISTING      = 1
       OTHERS                             = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    READ REPORT METHOD INTO I_PROGRAM.
    Please help me out in this regard.
    Thanks & Regards,
    Radhika

  • Got javax.transaction.HeuristicMixedException  when calling EJB business methods

              I have developed two EJBs. One is a stateless session bean,
              called InventorySessionBean(JNDI name: Inventory); the other one
              is a CMP Entity Bean called InventoryBean(JNDI name:
              InventoryBean). The InventoryBean represents the business object
              of Inventory. InventoryBean is declared CMT and all methods in
              the beans have attribute "Required". The InventorySessionBean is a session facade
              which encapsulate the business methods of
              InventoryBean. InventorySessionBean is declared CMT and all
              methods in the bean have attribute"RequiresNew" The backend
              database is Ingres.
              I have setup JDBC connection pool, Datasource and Tx Datasource.
              There is a client program which invokes InventorySessionBean to get business data
              from database.
              Actually the InventorySessionBean invokes InventoryBean entity bean to get data
              from database.
              After I starting up the weblogic server, I ran the client program to get data,
              everything works fine.
              After a period of time (about 50 minutes ) from starting the WLS server, I reran
              the client program.
              I got following exceptions:
              Exception while commiting Tx : Name=[EJB com.memec.na.mppl.businessobjects.inventory.InventorySessionBean.getPriceAndAvailability(java.lang.String,ja
              va.lang.String,java.lang.String,java.lang.String)],Xid=4:916d7da2142a593c(2094524),Status=Committed,HeuristicErrorCode=XA_HEURHAZ,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds
              since begin=3,seconds left=119,ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=committed,assigned=leiWLS),SCInfo
              [leiwang+leiWLS]=(state=committed),properties=({weblogic.transaction.name=[EJBcom.memec.na.mppl.businessobjects.inventory.InventorySessionBean.getPriceAndAvailability(java.lang.String,java.lang.String,java.lang.String,java.lang.String)],
              weblogic.jdbc=t3://10.1.129.124:7001}),OwnerTransactionManage
              r=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=leiWLS+10.1.129.124:7001+leiwang+,
              Resources={})],CoordinatorURL=leiWLS+10.1.129.124:7001+leiwa
              ng+); nested exception is:
              javax.transaction.HeuristicMixedException: (weblogic.jdbc.jts.Connection,
              HeuristicHazard, (javax.transaction.xa.XAException: Error dequeueing
              message for statement connection # 23 type S))
              java.rmi.RemoteException: Exception while commiting Tx : Name=[EJB com.memec.na.mppl.businessobjects.inventory.InventorySessionBean.getPriceAndAvailab
              ility(java.lang.String,java.lang.String,java.lang.String,java.lang.String)],Xid=4:916d7da2142a593c(2094524),Status=Committed,HeuristicErrorCode=XA_HEU
              RHAZ,numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=3,seconds left=119,ServerResourceInfo[weblogic.jdbc.jts.Connection]=(state=committe
              d,assigned=leiWLS),SCInfo[leiwang+leiWLS]=(state=committed),properties=({weblogic.transaction.name=[EJB
              com.memec.na.mppl.businessobjects.inventory.In
              ventorySessionBean.getPriceAndAvailability(java.lang.String,java.lang.String,java.lang.String,java.lang.String)],
              weblogic.jdbc=t3://10.1.129.124:7001
              }),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=leiWLS+10.1.129.124:7001+leiwang+,
              Resources={})],CoordinatorURL=leiWL
              S+10.1.129.124:7001+leiwang+); nested exception is:
              javax.transaction.HeuristicMixedException: (weblogic.jdbc.jts.Connection,
              HeuristicHazard, (javax.transaction.xa.XAException: Error dequeueing
              message for statement connection # 23 type S))
              javax.transaction.HeuristicMixedException: (weblogic.jdbc.jts.Connection, HeuristicHazard,
              (javax.transaction.xa.XAException: Error dequeueing message
              for statement connection # 23 type S))
              at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:237)
              at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:190)
              at weblogic.ejb20.internal.BaseEJBObject.postInvoke(BaseEJBObject.java:231)
              at com.memec.na.mppl.businessobjects.inventory.InventorySessionBean_9wgxw_EOImpl.getPriceAndAvailability(InventorySessionBean_9wgxw_EOImpl.jav
              a:224)
              at com.memec.na.mppl.processors.Outbound3A2Processor.getData(Outbound3A2Processor.java:202)
              Stop the WLS server and restart it again. Everything works well.
              Any comments to this problem would be really appreciated. Thanks.
              

    Hi
    I was using the session bean.Your suggestion helped me a lot.Perfect.
    I debug my program and found that from ejbCreate()exception is getting.
    I was getting the datasource object thro ejb create() initialisation.
    Somehow the look up jndi which i mentioned was not interpretting from ejb-jar.xml ias-ejb-jar.xml and datasource ref .Due to this iam getting jndi Namenotfound exception which in turns to null pointer as datasource is getting null.
    when i hardcoded in the ejb the the jndi name for datasource it is working fine.Bit worried all the existing ejbs working with the xml referenced datasource and jndi,but when i added a new ejb with same properties it is failing to get the jndi name.
    Piece of code from ias-ejb-jar.xml
    <resource-ref>
              <res-ref-name>myDataSource</res-ref-name>
              <jndi-name>jdbc/nb/myData</jndi-name>
    </resource-ref>
    Piece of code from ejb-jar.xml
    <resource-ref>
              <res-ref-name>myDataSource</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
    </resource-ref>
    Thanks a lot meka

  • Getting error while calling ejb business methods from servlet

    Hi
    Iam getting error when i try to call a ejb method from servlet.Error is
    "com.netscape.server.eb.UncheckedException: unchecked exception nested exception is:java.lang.NullPointerException".
    I build the application and deployed it successfully.Iam using IAS 6.O with windows NT 4.0.
    This is just a method which takes values from database and return as an array of bean to servlet.
    Any help on this.Thanks Shank

    Hi
    I was using the session bean.Your suggestion helped me a lot.Perfect.
    I debug my program and found that from ejbCreate()exception is getting.
    I was getting the datasource object thro ejb create() initialisation.
    Somehow the look up jndi which i mentioned was not interpretting from ejb-jar.xml ias-ejb-jar.xml and datasource ref .Due to this iam getting jndi Namenotfound exception which in turns to null pointer as datasource is getting null.
    when i hardcoded in the ejb the the jndi name for datasource it is working fine.Bit worried all the existing ejbs working with the xml referenced datasource and jndi,but when i added a new ejb with same properties it is failing to get the jndi name.
    Piece of code from ias-ejb-jar.xml
    <resource-ref>
              <res-ref-name>myDataSource</res-ref-name>
              <jndi-name>jdbc/nb/myData</jndi-name>
    </resource-ref>
    Piece of code from ejb-jar.xml
    <resource-ref>
              <res-ref-name>myDataSource</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
    </resource-ref>
    Thanks a lot meka

  • Get row id after EJB create method.

    Hi,
    does any one know how to get an id of new created by CMP ejb row? When I create new object it's id is 0, when i call ejb create it creates new row in DB and crates new ID by increasing the old one, but how can I get this new ID after create has finished?
    Now I have to look equals by some fields object in DB after creation, looks ugly.

    So here is my CMP :
    * @ejb.bean name="Dividend"
    * type="CMP"
    * view-type="local"
    * primkey-field="id"
    * schema="dividends"
    * cmp-version="2.x"
    * @ejb.value-object name="Dividend"
    * match="*"
    * @ejb.transaction type="Required"
    * @ejb.persistence table-name="dividends"
    * @ejb.finder signature="Collection findAll()"
    * query="SELECT OBJECT(d) FROM dividends d"
    * @jboss.query signature="Collection findAll()"
    * @ejb.finder signature="Dividend findByActivityId(java.lang.Integer activityId)"
    * query="SELECT OBJECT(d) FROM dividends d WHERE d.activityId = ?1"
    * @jboss.query signature="Dividend findByActivityId(java.lang.Integer activityId)"
    * strategy="on-load"
    * @jboss.persistence create-table="false"
    * remove-table="false"
    * datasource="java:/ChronimDS"
    * datasource-mapping="mySQL"
    public abstract class DividendBean implements EntityBean {
    //~ Methods ----------------------------------------------------------------
    //==========================================
    // Business methods
    //==========================================
    * @ejb.interface-method
    public Dividend getDividend() {
    Dividend dividend = new Dividend();
    dividend.setId(this.getId());
    dividend.setActivityId(this.getActivityId());
    dividend.setLower(this.getIsLower());
    dividend.setLowerAmount(this.getLowerAmount());
    return dividend;
    * @ejb.interface-method
    public void setDividend(Dividend dividend) {
    this.setActivityId(dividend.getActivityId());
    this.setIsLower(dividend.isLower());
    this.setLowerAmount(dividend.getLowerAmount());
    //==========================================
    // CMP fields
    //==========================================
    * @ejb.pk-field
    * @ejb.persistence column-name="id"
    * jdbc-type="INTEGER"
    * sql-type="INTEGER"
    * @ejb.interface-method
    * @ejb.transaction type="NotSupported"
    public abstract Integer getId();
    public abstract void setId(Integer id);
    * @ejb.persistence column-name="activityId"
    * jdbc-type="INTEGER"
    * sql-type="INTEGER"
    public abstract Integer getActivityId();
    public abstract void setActivityId(Integer activityId);
    * @ejb.persistence column-name="isLower"
    * jdbc-type="TINYINT"
    * sql-type="TINYINT"
    public abstract boolean getIsLower();
    public abstract void setIsLower(boolean isLower);
    * @ejb.persistence column-name="lowerAmount"
    * jdbc-type="INTEGER"
    * sql-type="INTEGER"
    public abstract Integer getLowerAmount();
    public abstract void setLowerAmount(Integer lowerAmount);
    //==========================================
    // EJB callbacks
    //==========================================
    * @ejb.create-method
    public Integer ejbCreate(Dividend dividend)
    throws CreateException {
    this.setId(dividend.getId());
    this.setIsLower(dividend.isLower());
    this.setLowerAmount(dividend.getLowerAmount());
    this.setActivityId(dividend.getActivityId());
    return null;
    public void ejbPostCreate(Dividend dividend)
    throws CreateException {
    // EntityBean (empty) implementation
    public void setEntityContext(javax.ejb.EntityContext ec) {
    public void unsetEntityContext() {
    public void ejbLoad() {
    public void ejbStore() {
    public void ejbActivate() {
    public void ejbPassivate() {
    public void ejbRemove() {
    As you can see I'm using xdoclets.
    Suppose I need to create new row of this object :
    Dividend d = new Dividend();
    // fill dividend by values here but do not set it's id it is 0 before creation
    // SQL server will set it automaticly
    Object ref = context.lookup("DividendLocal");
    DividendLocalHome dividendLocal = (DividendLocalHome) ref;
    dividendLocal.create(dividend)
    I create new row of dividend in my DB and want to get an ID of the new created row, I thought that dividend object will get this ID after creation automaticly, but no, his id is 0.
    so here id will be 0 :
    dividendLocal.create(dividend);
    int id = dividend.getId(); // 0
    and if I write this
    dividendLocal.create(dividend).getId();
    I get :
    2007-06-25 14:44:02,384 ERROR [org.jboss.ejb.plugins.LogInterceptor]
    EJBException in method: public abstract java.lang.Integer
    com.xxx.xxx.ejb.SessionFacade.createDividend(
    xxx.xxx.model.Contract) throws java.rmi.RemoteException:
    javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=0

  • EJB CMP remove create cache issue? DuplicateKeyException

    EJB CMP remove create cache issue? DuplicateKeyException
    Hi I have an EJB 2.1 application using CMP. Most things work fine. But if I in a transaction tries to remove a bean and create a new one with the same primary key I get a DuplicateKeyException:
    2007-11-16 09:25:31,963 ERROR [RMICallHandler-6] AdminGroupData_ConcreteSubClass147 - Error adding AccessRules:
    javax.ejb.DuplicateKeyException: Exception [EJB - 10007]: Exception creating bean of type [AccessRulesData]. Bean already exists.
    at oracle.toplink.internal.ejb.cmp.EJBExceptionFactory.duplicateKeyException(EJBExceptionFactory.java:195)
    I suspect that the remove call only removes from the cache (until commit), but that the create call checks the database or something?
    My code is simple like the following:
    AdminPreferencesDataLocal apdata1 = adminpreferenceshome.findByPrimaryKey(certificatefingerprint);
    adminpreferenceshome.remove(certificatefingerprint);
    adminpreferenceshome.create(certificatefingerprint,newadminpreference);
    Is there some configuration I can set in toplink-ejb-jar.xml to fix this?
    I use OC4j 10.1.3.3
    Cheers,
    Tomas

    The bean.remove() was executed but the sql DELETE was executed to the database as the result, oc4j manages all sql statements and they are optimized to commit to the database in batch at once when the transaction commit. Oc4j ejb container is smart and preventing you from creating the same entity cached in the transaction because the sql delete was not really committed to the database when the create is called.
    My guess is that the reason it works with IBM WAS was because it issued sql for each remove/create call right away instead of doing them in batch as oc4j, or your WAS remove then create were called in separate transactions.

  • Dynamic  action - execute pl/sql code

    Hi All and thanks fro any assistance.
    I am trying to Execute the following pl/sql Code in a dynamic action however get the following error - AJAX call returned server error ORA-01403: no data found for Execute PL/SQL code.
    I have all page items iin the page items to submit section.
    declare
      l_file_comments  IMM_DOCUMENTS.FILE_COMMENTS%type;
      l_file           IMM_DOCUMENTS.FILE_BLOB%type;
      l_filename       IMM_DOCUMENTS.FILENAME%type;
      l_mimetype       IMM_DOCUMENTS.FILE_MIMETYPE%type;
      l_charset        IMM_DOCUMENTS.FILE_CHARSET%type;
    begin
        select f.blob_content,
               f.filename,
               f.mime_type,
               nvl(f.file_charset, f.dad_charset)
          into l_file,
               l_filename,
               l_mimetype,
               l_charset
          from wwv_flow_files f
         where f.name = :P80_FILE;
      if l_file is not null then
        insert into IMM_DOCUMENTS
          sub_id,
          document_type_id,
          filename,
          file_blob,
          file_comments,
          file_mimetype,
          file_charset
        values
          :P80_SUB_ID,
          :P80_DOCUMENT_TYPE_ID,
          l_filename,
          l_file,
          :P80_FILE_DESCRIPTION,
          l_mimetype,
          l_charset
        delete from wwv_flow_files where name = :P80_FILE;
      end if;
    end;

    Hi Marie,
    as Matthew says, the only part of the code that could result in that error is the select into statement. This is because, in pl/sql, a select into statement is expected to return one row only. If it returns no rows it raises a no data found exception and if it returns more than one row it raises a too many rows error.
    If it is acceptable that this query may return no rows, then you have to handle this situation. The two methods that you can use would be firstly to use a named cursor and fetch a row from this, if there is no data then it does not raise an exception. The other method would be to put in an exception handler around the select statement.
    EG - prefered, mainly because I think it is better to code in a way that minimises exception handling.
    declare
       l_file_comments  IMM_DOCUMENTS.FILE_COMMENTS%type;
       l_file           IMM_DOCUMENTS.FILE_BLOB%type;
       l_filename       IMM_DOCUMENTS.FILENAME%type;
       l_mimetype       IMM_DOCUMENTS.FILE_MIMETYPE%type;
       l_charset        IMM_DOCUMENTS.FILE_CHARSET%type;
       CURSOR file_cur IS
         select f.blob_content,
                f.filename,
                f.mime_type,
                nvl(f.file_charset, f.dad_charset)
           from wwv_flow_files f
          where f.name = :P80_FILE;
    begin
       OPEN file_cur;
       FETCH file_cur INTO
                l_file,
                l_filename,
                l_mimetype,
                l_charset;
       CLOSE file_cur;
       if l_file is not null then
         insert into IMM_DOCUMENTS
           sub_id,
           document_type_id,
           filename,
           file_blob,
           file_comments,
           file_mimetype,
           file_charset
         values
           :P80_SUB_ID,
           :P80_DOCUMENT_TYPE_ID,
           l_filename,
           l_file,
           :P80_FILE_DESCRIPTION,
           l_mimetype,
           l_charset
         delete from wwv_flow_files where name = :P80_FILE;
       end if;
    end;
    OR
    declare
      l_file_comments  IMM_DOCUMENTS.FILE_COMMENTS%type;
      l_file           IMM_DOCUMENTS.FILE_BLOB%type;
      l_filename       IMM_DOCUMENTS.FILENAME%type;
      l_mimetype       IMM_DOCUMENTS.FILE_MIMETYPE%type;
      l_charset        IMM_DOCUMENTS.FILE_CHARSET%type;
    begin
      BEGIN
        select f.blob_content,
               f.filename,
               f.mime_type,
               nvl(f.file_charset, f.dad_charset)
          into l_file,
               l_filename,
               l_mimetype,
               l_charset
          from wwv_flow_files f
         where f.name = :P80_FILE;
      EXCEPTION
        WHEN no_data_found THEN
          NULL;
      END;
      if l_file is not null then
        insert into IMM_DOCUMENTS
          sub_id,
          document_type_id,
          filename,
          file_blob,
          file_comments,
          file_mimetype,
          file_charset
        values
          :P80_SUB_ID,
          :P80_DOCUMENT_TYPE_ID,
          l_filename,
          l_file,
          :P80_FILE_DESCRIPTION,
          l_mimetype,
          l_charset
        delete from wwv_flow_files where name = :P80_FILE;
      end if;
    end;Note : code is untested.
    Regards
    Andre

  • How to 100% Protect PL/SQL Code By Wrapped in Oracle Database 10g R2

    Hello,
    Is Possible to 100% Protect PL/SQL Code By Wrapped in Oracle 10g R2 ?
    If it is not possible by wrap in oracle 10g R2,
    Please, let me suggest, how i will be able to 100% protect PL/SQL code in Oracle Database 10g R2.
    Because, I have lot of functions, procedures & package's in my project.
    Which is running in field filed.
    So, i have needed to protect 100%.
    Also, will i convert to al functions, procedures & package's to .pll file ?
    And .pll file to .plx file?
    Is it possible to convert .plx file to .pll file ?
    Please, let know any better solutions in this case....
    Regards
    Mehedi

    Hello,
    No, wrapping is not a 100% secure method. It could prevent your code from amateurs, but not from professional hackers. Look at the article http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/wrap.htm#BEHGBJAA
    It says: "•Wrapping is not a secure method for hiding passwords or table names.
    Wrapping a PL/SQL unit prevents most users from examining the source code, but might not stop all of them."
    Edited by: apiminov on 03.12.2012 3:23
    Edited by: apiminov on 03.12.2012 3:24

  • Where to put javascript code?

    Hello,
    I am trying to set some columns in a list as "read-only" and is using the following code:
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById(’4_ctl00_ctl00_TextField’);
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push(“SetReadOnly()”);
    </script>
    But I am not sure where to put the code in. Should I put it in the space in Content Editor Web Part,
    or through a link to a txt file, or in "Edit HTML"? I've tried them but none works.
    Thanks a lot!
    Patrick

    You can try this:
    1) Open your Sharepoint List. Go to List edit view.
    2) On right side of Ribbon you will find "Form Web Parts" option as shown in figure.
    3) Choose your List form which you want to edit.
    4) Now you can add web part in new window.
    5) Add Content Editor Web part.
    6) In content editor web part add the path of your "txt" file in which you have written your script, for eg.
    <!DOCTYPE html>
    <html>
    <body>
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById('4_ctl00_ctl00_TextField');
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push("SetReadOnly()");
    </script>
    </body>
    </html>
    I haven't tried this method so I am not sure but hope it works...:D
    ***If my post is answer for your query please mark as answer***
    ***If my answer is helpful please vote***

  • Funny bug in pl sql code

    Hi,
    I have written a code to upload data from csv file to oracle table. it gives me a funny error. I have given below the sample contents of .csv file
    "4951","TCSPL (TRADING A/C)","470","TISCO",20050419,"P",362.6550,212,0.00
    "4951","TCSPL (TRADING A/C)","470","TISCO",20050419,"S",361.7500,212,-191.86
    "4951","TCSPL (TRADING A/C)","477","ASHOKLEY",20050928,"P",28.5000,200,0.00
    "4951","TCSPL (TRADING A/C)","477","ASHOKLEY",20050928,"S",28.4960,200,-0.80
    for the first time if i run the sql code it uploads first 2 records and does not upload third record, if i change the figure of =-191.86 to 191.86 (if i remove - mark ) then it uploads all the records, if i reverse it back it does not the third record, the structure of the table is like this ( the data column where this data get inserted is number(15,4) datatype)
    this type of problem is happening with that perticular row only, though several such kind of combination is there in the csv file.
    sQL> desc UNITISCLTRXN
    Name Null? Type
    CLCODE VARCHAR2(10)
    CLNAME VARCHAR2(120)
    SCCODE VARCHAR2(10)
    NSESYMBOL VARCHAR2(10)
    TRDDATE DATE
    PURSAL VARCHAR2(1)
    RATE NUMBER(15,6)
    CLQTY NUMBER(10,2)
    PROFIT NUMBER(15,4)
    the sql code i have written is as below
    PROCEDURE upload_unitiscltrxn IS
    file_id text_io.file_type;
         crec unitiscltrxn%rowtype;
    linebuf VARCHAR2(1000);
    i number:=1;
    len number:=0;
    spos number:=0;
    tpos number:=0;
    var varchar2(1000);
    mon varchar2(5);
    cnt number:=0;
         errnum NUMBER := ERROR_CODE;
         errtxt VARCHAR2(80) := ERROR_TEXT;
    errtyp VARCHAR2(3) := ERROR_TYPE;
    begin
              Delete from unitiscltrxn;
              File_id := Text_IO.Fopen('M:\UNITIS\db\final.csv', 'r');
         Text_IO.Get_Line(File_id,linebuf);
              cnt :=1;
              while linebuf is not null loop
         IF CNT<>1 THEN
              Text_IO.Get_Line(File_id,linebuf);
         END IF;     
              cnt :=1+cnt;
         len := length(linebuf);
         spos :=1;
         i:=1;
         tpos :=0;
         var:='';
         mon:='';     
         while i < 10 loop
         tpos := instr(linebuf,',',spos);
         if tpos >0 then
              var :=substr(linebuf,spos,tpos-spos);
         else
              var :=substr(linebuf,spos);
         end if;     
              ----------get values into variable.------------------     
         If i =1 then
              Crec.clcode := Replace(var,'"','');
         ElsIf     i =2 then
              Crec.clname := Replace(var,'"','');
         ElsIf     i =3 then
              Crec.sccode := Replace(var,'"','');
         ElsIf     i =4 then
              Crec.nsesymbol := Replace(var,'"','');
         ElsIf     i =5 then
              select Decode(substr(var,5,2),1,'JAN',2,'FEB',3,'MAR',4,'APR',5,'MAY',6,'JUN',7,'JUL',8,'AUG',
              9,'SEP',10,'OCT',11,'NOV',12,'DEC') into mon from dual;
              Crec.trddate := to_date(substr(var,7)||'-'||mon||'-'||substr(var,1,4),'DD-MON-YYYY');
         ElsIf     i =6 then
              If var = '"P"' Then
                   Crec.pursal :='P';
              Elsif     var = '"S"' Then
                   Crec.pursal :='S';
              end if;     
              --Crec.pursal := var;
         ElsIf     i =7 then
              Crec.rate := var;
         ElsIf     i =8 then
              Crec.clqty := var;
         ElsIf     i =9 then
              Crec.profit := var;
         End If;     
         i:=i+1;
         spos:=tpos+1;
         end loop;
         INSERT INTO UNITISCLTRXN VALUES(crec.clcode, crec.clname ,crec.sccode ,crec.nsesymbol,
         crec.trddate,crec.pursal,crec.rate,crec.clqty,crec.profit);
         text_io.new_line(file_id, 1);
         End loop;     
         EXCEPTION
         WHEN no_data_found THEN
         Text_IO.Put_Line('Closing the file...');
         Text_IO.Fclose(file_ID);
    WHEN OTHERS THEN
         Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt||'FF'||DBMS_ERROR_CODE);
         Message(errtyp||'-'||TO_CHAR(errnum)||': '||errtxt);
    END;
    END;
    Thanks
    Uday

    Hi
    Try to debug you procedure inserting a better exception handling and some dbms_output.put_line.
    E.g.
    ElsIf i =9 then
    Crec.profit := var;
    dbms_output.put_line(var || '  -  ' Crec.profit);
    End If; Try to put the exception handling in the loop ... while i < 10 loop ... .
    I don't think that it's an Oracle bug. It's a human error in your code!
    Bye, Aron

Maybe you are looking for

  • Screensaver eMac monitor while in extended desktop mode?

    Officially, eMacs can mirror to an external display but cannot do extended desktop. Since my 2005 eMac's built-in monitor is only functioning correctly at low resolutions (see http://discussions.apple.com/thread.jspa?threadID=2013835), I'm using a pr

  • Airplay Icon not Showing when connected to my car's bluetooth stereo

    I have an UVO system in my Kia. It has been working great with the Iphone Airplay since October. I recently updated my phone and now, just like many others, no airplay showing up on my music apps. I basically use Spotify and Pandora all the time with

  • Sync iPod with iTunes - reduce network bandwidth for iTunes music folder

    I'm using a network drive for my iTunes music folder. Average bandwidth is 50Mbps, compared to, say, an external USB HDD with hi-speed USB bandwidth of 750Mbps. For some reason iTunes needs to consult the files in the iTunes music folder when syncing

  • Exporting from Premiere Pro CC 2014

    Hello there, Every time that I am willing to export my project my Premiere Pro CC 2014 stop responding all together. I tried the short cut (Commend+M) or going through the Manu bar. the result is the same, Premiere Pro CC 2014 just freezes and does n

  • Programa para fazer download de musicas

    Gostaria de instalar um programa para fazer download de musicas e não encontro um programa compatível, gostaria de uma recomendação. Obrigado.