Sequence in Impl create() method + UIX

I am populating a key from a database sequence from
the entity ???Impl create() method. It tests out OK from
the tester and any generated browse and edit forms except the UIXML. I can see it being called twice from a UIXML browse and edit form; once to create the row before the page is rendered and then again during the 'apply' event.
It ends up wasting every other sequence number. Any ideas on how to stop this?
* Add attribute defaulting logic in this method.
protected void create(AttributeList attributeList) {
super.create(attributeList);
SequenceImpl seq =
new SequenceImpl("REGION_SEQ", getDBTransaction());
Number sval = seq.getSequenceNumber();
setRegionId(sval);
System.out.println("create: sval " + sval);
}

I believe that the technique that is described by Steve Muench in that article leaves one problem area open. Using the DBSequence domain requires that a trigger be on the database to create the sequence number for the new record. If you need to know what that sequence number is immediately after it was created you will need to do some extra coding to identify it.
I am not sure what you mean that you would use doDML(). Can you explain further?
Still, the technique that uses create(), that is also published in the Oracle9i JDeveloper Handbook, should work. I believe that Oracle has recognized this as a bug and plans to have it fixed in the next release.

Similar Messages

  • How can i override the default create operation UIX ADF STRUTS

    Hi dear forum:
    How can I customize the default create operation?
    I need to calculate a value and put it into the new row created.
    Please help me!!!

    Hi,
    if you are usimng Business Components,
    1. Select the Entity Object and double click on it
    2. Select the Java node
    3. Check the "Create Method" checkbox
    4. click OK
    5. Open the <eo name>Impl.java file created (need to see this in System navigator view)
    6. Search for the set<Attribute name>() method and add your calculation for this attribute
    Frank

  • Initializing Attributes in create() method

    We're currently using the BC4J framework within the Struts context. I'm trying to initialize non-constant attributes (e.g., current date) in the create(AttributeList) method of an xxxEntityImpl class, but when I try to commit the transaction, it fails.
    I know the problem has to do with the fact that BC4J (within the Struts context, at least) creates an emtpy Entity object when the user selects the "new" link, and uses this entity to populate the entry form, then creates a new entity when the form is posted. (This also causes the wasted sequence value, but we've worked around that issue.) When any attributes are set in the create() method, the first entity is added to the pending transaction because it has changed. However, we only want the second entity (created on form post) in the transaction. Is there any work around for this?
    Any help would be much appreciated.
    Thanks,
    Patrick

    You MUST provide an organizatation name. There is a system entity adapter on the Users data object. You cannot avoid populating this.
    -Kevin

  • Edit entity object and use the Create() method for generating ID's

    Hello,
    I have and InserPage.jsp and defined the datasoucre correctly.
    <jbo:InputText datasource="ds" dataitem="Clientid" /> gives me
    the unique ClientID from the FIRST client-record in my table ,
    although this page is for inserting a NEW Client, with a new
    ClientID.
    So, on the Clients Entity i made a create() method and put the
    following code in it:
    public Number getClientid() {
    return (Number)getAttributeInternal(CLIENTID);
    public void create(AttributeList attributeList) {
    SequenceImpl seq = new SequenceImpl
    ("Clientid",getDBTransaction());
    Integer i=(Integer)seq.getData();
    setClientid(new Number(i.intValue()));
    super.create(attributeList);
    the getData() Returns a sequence value, but what sequence value?
    Do i have to create a sequence on the ClientID column in my
    Oracle Table in the DB too?
    The problem is, the first ClientID # is 819 and the current last
    one seems to be 2899, so how do i achieve that when opening the
    insert.jsp the new ClientID shows up (ie. 2900)?
    How can i achieve this?
    thx

    OK, managed to track down the HowTo on triggers? I created the
    trigger.
    create sequence client_seq
    start with 8900
    increment by 1
    nomaxvalue
    nocycle;
    I changed the create() method for the entity object to:
    public void create(AttributeList attributeList) {
    SequenceImpl seq = new SequenceImpl
    ("Clientid",getDBTransaction());
    SequenceImpl s = new SequenceImpl("client_seq",
    getDBTransaction());
    Integer next = (Integer)s.getData();
    setClientid(new Number(next.intValue()));
    and running the tester for the module works fine. ;-)
    But...
    The Insert.jsp page has to insert/show this sequenced value!
    After i defined the datasource and let us say:
    <jbo:InputText datasource="ds" dataitem="Clientid" />
    ...the number 819 shows up, which is the FIRST record, so i do
    not get the new ClientID with the correct number.
    Any help is always nice. ;-)

  • CL_RSPLS_CR_EXIT_BASE  how to use the create method

    Hi everybody
    I am using a copy of CL_RSPLS_CR_EXIT_BASE in the relationships derivation of our planning project. I do not understand how CL_RSPLS_CR_EXIT_BASE works.
    Here is the problem:
    I use the class to derivate 0COSTCENTER from 0CO_AREA and 0COORDER. In one planning function everything works fine. With the use of the relationships the class is called and in the DERIVATE Method I can select the responsible costcenter from the 0COORDER data with 0COORDER and 0CO_AREA.
    But I also have a planning sequence which is also using the relationships but on step 7 (costcenter from co_area and coorder) it directely calls the DERIVATE method. But in the DERIVATE Method I do not have the source fields COORDER and CO_AREA as source data available....
    How does this work? Where do I get the source data from? In the first case I have it all in the parameter c_s_chas.... but in the CREATE method I can't find the source data.
    Thanks for any input.
    Have a nice day
    regeards
    Christophe

    Hi Gregor
    thanks for your reply. I definitely am or was pretty confused about DERIVE and CREATE. Can you confirm the following so that I know if I got it now:
    In CREATE i select data from the master table (for example COSTCENTER COORDER and CO_AREA if those are the characteristics I use in the exit relation (source = COORDER, target = COSTCENTER and CO_AREA). Those are also the lines I find in the selection criteria table i_tsx_seldr.
    I fill all the selected combinations into the internal table e_th_chas (in the same order of fields like they are in i_tsx_seldr).
    That's it and then the system gets the necessery data from this selection?
    In this way I get a new error message in my planning sequence:
    Nachwert-Einschränkung 1 zu Teilvorgang 1 bewirkt folgenden Fehler
    Es konnte keine Kombination erzeugt werden
    What am still doing wrong?
    Thanks a lot!
    best regards
    christophe

  • Overriding create method

    I am trying to set the default date as the current date. On the forum everybody says to override the create() method. How do I do this?

    Hi,
    Go to the VO editor and select the Java node. Check the checkbox for creating the <VO>Impl class. Open this class and select Source--> Override Methods from the menu
    Use setAttribute() to set the default values
    public Row createRow() {
    Row rw = super.createRow();
    final String RESERVATIONDATE = "ReservationDate";
    final String CHECKIN = "Checkin";
    Date today = new Date(Date.getCurrentDate());
    //set default dates
    rw.setAttribute(RESERVATIONDATE,today);
    rw.setAttribute(CHECKIN,today);
    return rw;
    Please see: http://download-uk.oracle.com/docs/html/B25947_01/toc.htm

  • Multiple create methods of entity beans in single transcation

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

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

  • How to override the create method invoked by a create form?

    Hello everyone, I'm using ADF Faces and have the next question:
    How can I override the create method which is invoked by a create form to preset an attribute in the new row (the preset value is not fixed, I have to send it to the method as a parameter as it is obtained using an EL expression)?
    In the ADF guide I read how to override a declarative method (Section 17.5.1 How to override a declarative method), but this explains how to do it with a method that is called by a button. I don't know how to do the same with a method which is called automatically when the page is loaded.
    I also tried overriding the view object's createRow() method to receive a parameter with the preset values but it didn't work, I believe that was because the declarative create method is not the same as the view object's createRow. This caused the form to display another row from the viewobject and not the newly created one (I also set the new row into STATUS_INITIALIZED after setting the attribute).
    Well, I hope my problem is clear enough for somebody to help me.
    Thank you!

    Hello,
    I'm not sure you can do it with standard generated Create Form.
    In your view object you'll need to create your own create method with parameters, publish it to client interface and invoke instead of standard generated create action in page definition.
    Rado

  • Can I have a pack path in the XmlWriter.Create() method?

    Hi Everyone,
    This piece of code is throwing "The given path's format is not supported" error!
    var settings = new XmlWriterSettings();
    settings.Indent = true;
    var writer = XmlWriter.Create("pack://application:,,,/Languages;component/English.xaml", settings);
    System.Windows.Markup.XamlWriter.Save(rd, writer);
    writer.Close();
    Is there restrictions on the type of path we can provide in Create() ?
    Please Mark as Answered If this answers your question Or
    UnMark as Answered if it did not.
    Happy to Help :)
    My Site

    >>Can I have a pack path in the XmlWriter.Create() method?
    No you can't. Pack URIs are resource identifiers and the XmlWriter.Create method accepts an output file path and this path is relative to the directory of the running executable (.exe), i.e. the method simply creates a file on the disk.
    Whether this file is actually resides in your project folder or not doesn't matter at all as far as the XmlWriter is concerned.
    Please remember to mark helpful posts as answer and/or helpful and please start a new thread if you have a new question.

  • Using ADF View object create method in Data Action

    I need to know how to create a new row in an application module method and get the attributes from the ADF input form.
    If i Drag drop the create method in the data action form it is working fine. But how to do this programmatically, I have a need where i need to execute a query on another view object and set the create method.
    Thanks.

    Steven:
    (My application does not need to show all records and provide Edit/ Remove buttons at row level, navgational buttons and Create button for inserting new record. Instead, I would just open a blank record for entry, and commit)
    As per your post, I followed the following steps (action class) to insert blank record:
    DCBindingContainer bindings = actionContext.getBindingContainer();
    DCControlBinding binding = bindings.findCtrlBinding("Id");
    Row row = binding.getRowIterator().createRow();
    row.setNewRowState(row.STATUS_INITIALIZED);
    RowSetIterator rs =(RowSetIterator)
    binding.getRowIterator();
    rs.insertRow(row);
    End Results: It works fine and a new blank record is created. The only problem is <html:errors/> in JSP throws error for the first time. I do not want to elliminate error object from JSP.
    Please help!
    Thanks in advance

  • In Premiere Elements 11 I get this error message, unable to access location sequence 01/for creating

    The total error message is: unable to access location sequence 01/for creating temporary burning files
    What is this and how do I fix it.

    Some of this may be for Premiere Pro, but the IDEAS are the same for all Adobe software
    I am on Windows, but have a few saved Mac discussions that may help (or, may not... but free to read)
    Mac and Root User http://forums.adobe.com/thread/879931 -and http://forums.adobe.com/thread/940869?tstart=0
    Troubleshooting guide for Mac freeze
    http://helpx.adobe.com/x-productkb/global/troubleshoot-system-errors-freezes-mac.html
    Mac 10.8.2 Bug w/PreElements http://forums.adobe.com/thread/1202216
    Mac FONTS w/PrElements-11 http://forums.adobe.com/thread/1201281
    External speakers stop playback http://forums.adobe.com/thread/1370072?tstart=0

  • How to write a create method for a table Not null fields

    Hi all,
    I have a table with four columns,
    process
    prs_seqid NUMBER(4) NOT NULL,
    prs_sbs VARCHAR2(2) NOT NULL,
    prs_name VARCHAR2(64) NOT NULL,
    description VARCHAR2(128)
    Where prs_seqid is primary key and prs_sbs is foreign key.
    I tried to create a CMP bean for this table. I am unable to write a record in table while I can read
    Records from table. These are the create methods
    public Long ejbCreate() throws CreateException {
    return null;
    public Long ejbCreate(Long newPrs_seqid, String newPrs_sbs, String newPrs_name) throws CreateException {
    prs_seqid = newPrs_seqid;
    newPrs_sbs = prs_sbs;
    prs_name = newPrs_name;
    return null;
    public void ejbPostCreate() {
    public void ejbPostCreate(Long newPrs_seqid, String newPrs_sbs, String newPrs_name) {
    When I run the client code �home.create(pk, "AB", "ABC");�
    It throws
    java.rmi.ServerException: RemoteException occurred in server thread; nested exce
    ption is:
    java.rmi.RemoteException: Transaction aborted (possibly due to transacti
    on time out).; nested exception is: javax.transaction.RollbackException; nested
    exception is:
    javax.transaction.RollbackException
    java.rmi.RemoteException: Transaction aborted (possibly due to transaction time
    out).; nested exception is: javax.transaction.RollbackException; nested exceptio
    n is:
    javax.transaction.RollbackException
    javax.transaction.RollbackException
    <<no stack trace available>>
    In log file I got
    java.sql.SQLException: ORA-01400: cannot insert NULL into ("SCOTT"."PROCESSES"."PRS_SBS")
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
         at com.sun.ejb.persistence.PersistenceManagerImpl.createRow(PersistenceManagerImpl.java:630)
         at com.sun.ejb.persistence.PersistenceManagerImpl.storeRow(PersistenceManagerImpl.java:412)
         at com.sun.ejb.persistence.PartitionImpl.ejbStore(PartitionImpl.java:555)
         at com.telesenskscl.processes.ProcessesBean_PM.ejbStore(ProcessesBean_PM.java:103)
         at com.sun.ejb.containers.EntityContainer.callEJBStore(EntityContainer.java:1581)
         at com.sun.ejb.containers.EntityContainer.enlistResourcesAndStore(EntityContainer.java:868)
         at com.sun.ejb.containers.EntityContainer.beforeCompletion(EntityContainer.java:853)
         at com.sun.ejb.containers.ContainerSynchronization.beforeCompletion(ContainerSynchronization.java:65)
         at com.sun.jts.jta.SynchronizationImpl.before_completion(SynchronizationImpl.java:48)
         at com.sun.jts.CosTransactions.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:108)
         at com.sun.jts.CosTransactions.TopCoordinator.beforeCompletion(TopCoordinator.java:2289)
         at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:233)
         at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:208)
         at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:386)
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:208)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:434)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:1460)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:1278)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:397)
         at com.telesenskscl.processes.ProcessesBean_PM_RemoteHomeImpl.create(ProcessesBean_PM_RemoteHomeImpl.java:41)
         at com.telesenskscl.processes._ProcessesBean_PM_RemoteHomeImpl_Tie._invoke(Unknown Source)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:519)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:204)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:112)
         at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
         at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
         at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)
    javax.ejb.EJBException: nested exception is: javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-01400: cannot insert NULL into ("SCOTT"."PROCESSES"."PRS_SBS")
    javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-01400: cannot insert NULL into ("SCOTT"."PROCESSES"."PRS_SBS")
    java.sql.SQLException: ORA-01400: cannot insert NULL into ("SCOTT"."PROCESSES"."PRS_SBS")
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
         at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
         at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
         at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
         at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:822)
         at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:1446)
         at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1371)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1900)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
         at com.sun.ejb.persistence.PersistenceManagerImpl.createRow(PersistenceManagerImpl.java:630)
         at com.sun.ejb.persistence.PersistenceManagerImpl.storeRow(PersistenceManagerImpl.java:412)
         at com.sun.ejb.persistence.PartitionImpl.ejbStore(PartitionImpl.java:555)
         at com.telesenskscl.processes.ProcessesBean_PM.ejbStore(ProcessesBean_PM.java:103)
         at com.sun.ejb.containers.EntityContainer.callEJBStore(EntityContainer.java:1581)
         at com.sun.ejb.containers.EntityContainer.enlistResourcesAndStore(EntityContainer.java:868)
         at com.sun.ejb.containers.EntityContainer.beforeCompletion(EntityContainer.java:853)
         at com.sun.ejb.containers.ContainerSynchronization.beforeCompletion(ContainerSynchronization.java:65)
         at com.sun.jts.jta.SynchronizationImpl.before_completion(SynchronizationImpl.java:48)
         at com.sun.jts.CosTransactions.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:108)
         at com.sun.jts.CosTransactions.TopCoordinator.beforeCompletion(TopCoordinator.java:2289)
         at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:233)
         at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:208)
         at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:386)
         at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:208)
         at com.sun.enterprise.distributedtx.J2EETransactionManagerImpl.commit(J2EETransactionManagerImpl.java:434)
         at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:1460)
         at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:1278)
         at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:397)
         at com.telesenskscl.processes.ProcessesBean_PM_RemoteHomeImpl.create(ProcessesBean_PM_RemoteHomeImpl.java:41)
         at com.telesenskscl.processes._ProcessesBean_PM_RemoteHomeImpl_Tie._invoke(Unknown Source)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPOAServerSC.java:519)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOAServerSC.java:204)
         at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC.java:112)
         at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
         at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProcessor.java:84)
         at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadPool.java:99)
    Please help me ASAP. Thanks in advance

    I found problem was with my code. I wrote
    newPrs_sbs = prs_sbs; instead of
    prs_sbs = newPrs_sbs;
    This solves my problem
    Thanks to all.....

  • Jdev10.1.3: Create an UIX XML Page; Problem: No UIX-Item available...

    hello, i am new to jdev. at the moment i'm trying to complete the tutorial "Developing Applications with Oracle ADF UIX". (http://www.oracle.com/technology/obe/obe9051jdev/uixTutorial/lesson_UIX.htm)
    my problem: i followed the instructions until i was told, to create an uix-xml page. the picture in the tutorial indicates that there should be an available adf-uix item, but in my jdev there isn't. i know, the tutorial is using an older version of jdeveloper but at least, there should be something similar to the adf-uix item in my jdev.
    i thought there is no need in installing some sort of uix files... or am i wrong?

    Hi,
    Oracle recommends JSF instead of UIX for new projects. If you want to use UIX, take JDeveloper 10.1.2 or 10.1.2.1 instead of 10.1.3.
    Regards,
    Georg

  • Calling a css user created method from jspx page in ADF faces

    Hi all,
    Can anyone help me out to solve an issue calling a css user created method from a jspx page.
    Note: The css method is not the default css method. It needs to be called using 'styleClass' attribute in any tag.
    Thanks
    Neha

    Hi,
    I am not an expert in CSS so I don't know what a css method is. However, CSS can be applied to components via EL accessing a managed bean that returns the sytle text
    Frank

  • 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

Maybe you are looking for