Entity bean for more than one table

Can an entity bean represent more than one phyical table in the database? (i.e. span tables) If so, how is it coded up?

Yes, probably either using BMP entity beans, or creating a database view of the two tables.
However, the actual implementation depends a lot on your database and EJB container. Since I didn't see any details of these in your post, I suggest you research the documentation for both your EJB container and database.
[Of-course, I'm assuming that you are already using a database and EJB container :-]
Are you familiar with the following Web sites:
http://java.sun.com/j2ee/tutorial/1_3-fcs/
http://www.theserverside.com
Have you read the specification?
http://java.sun.com/j2ee/download.html
Hope this helps.
Good Luck,
Avi.

Similar Messages

  • Persisting CMP bean over more than one table

    Hello,
    I was wondering if it is possible to persist an Entity Bean over more than
    one table using CMP. For example 3 attributes go in table A and 2 attributes
    go in table B.
    I can see this might come in handy when having some kind of inheritance in
    your architecture.
    Thanks,
    Rein Reezigt

    CMP are based on one DB object however object could be a database table or a
    view. You can create a view and base your bean on that view. This is mostly
    useful for read-only entity beans that just do select queries because databases
    have all kind of different restrictions on update froma view, ( for example
    ORACLE allows update to only one table in view). However in case you need a
    logical abstraction of multiple tables, consider EJB2.0 relations or a product
    like toplink for your object to relational mapping.
    Viresh Garg
    Principal Developer Relations Engineer
    BEA Systems
    Rein Reezigt wrote:
    Hello,
    I was wondering if it is possible to persist an Entity Bean over more than
    one table using CMP. For example 3 attributes go in table A and 2 attributes
    go in table B.
    I can see this might come in handy when having some kind of inheritance in
    your architecture.
    Thanks,
    Rein Reezigt

  • Mapping a CMP bean to more than one table

    Hello,
    I like to map a CMP bean to more than one table. I am using wlserver7.0 SP2. I
    have a VendorBean with a CMP field "comments" mapped to VENDOR_COMMENTS table.
    All other CMP fields in VendorBean are mapped to VENDOR table. Below is the snippet
    of weblogic-cmp-rdbms-jar.xml:
    <weblogic-rdbms-bean>
    <ejb-name>VendorBean</ejb-name>
    <data-source-name>sweepDataSource</data-source-name>
    <table-map>
    <table-name>VENDOR</table-name>
    <field-map>
    <cmp-field>expIndicator</cmp-field>
    <dbms-column>VENDOR_EXP_IND</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>vendorId</cmp-field>
    <dbms-column>VENDOR_SEQ_KEY</dbms-column>
    </field-map>
    </table-map>
    <table-map>
         <table-name>VENDOR_COMMENTS</table-name>
         <field-map>
    <cmp-field>vendorId</cmp-field>
    <dbms-column>VENDOR_SEQ_KEY</dbms-column>
    </field-map>
         <field-map>
    <cmp-field>comments</cmp-field>
    <dbms-column>VENDOR_COMMENT</dbms-column>
    </field-map>
    </table-map>
    As you can see, "vendorId" is the primary key cmp field mapped to VENDOR_SEQ_KEY
    column in both tables. The relationship between the table rows are 1 to 1. When
    I run ejbc, I get the exception below:
    [ejbc] weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[ Asserti
    on violated ]
    [ejbc] at weblogic.utils.Debug.assertion(Debug.java:74)
    [ejbc] at weblogic.ejb20.cmp.rdbms.RDBMSBean.processRole(RDBMSBean.java
    :1389)
    [ejbc] at weblogic.ejb20.cmp.rdbms.RDBMSBean.processDescriptors(RDBMSBe
    an.java:1105)
    [ejbc] at weblogic.ejb20.cmp.rdbms.Deployer.readTypeSpecificData(Deploy
    er.java:299)
    [ejbc] at weblogic.ejb20.persistence.PersistenceType.setTypeSpecificFil
    e(PersistenceType.java:490)
    [ejbc] at weblogic.ejb20.persistence.PersistenceType.setupDeployer(Pers
    istenceType.java:407)
    [ejbc] at weblogic.ejb20.deployer.CMPInfoImpl.setup(CMPInfoImpl.java:11
    4)
    [ejbc] at weblogic.ejb20.ejbc.EJB20CMPCompiler.generatePersistenceSourc
    es(EJB20CMPCompiler.java:64)
    [ejbc] at weblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:22
    3)
    [ejbc] at weblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:3
    44)
    [ejbc] at weblogic.ejbc20.runBody(ejbc20.java:470)
    [ejbc] at weblogic.utils.compiler.Tool.run(Tool.java:126)
    [ejbc] at weblogic.ejbc20.main(ejbc20.java:711)
    But if I put the "comments" <field-map> inside the VENDOR <table-map> and get
    rid off the <table-map> for VENDOR_COMMENTS, I was able to run ejbc. Of course,
    I get the run time exception during deployment because, there is no column called
    "VENDOR_COMMENT" in VENDOR table. Please help me. Thanks a million.

    Wrong newsgroup, needs to go to one of the ejb newsgroups.
    mbg
    "Sai S Prasad" <[email protected]> wrote in message
    news:[email protected]...
    >
    Hello,
    I like to map a CMP bean to more than one table. I am using wlserver7.0SP2. I
    have a VendorBean with a CMP field "comments" mapped to VENDOR_COMMENTStable.
    All other CMP fields in VendorBean are mapped to VENDOR table. Below isthe snippet
    of weblogic-cmp-rdbms-jar.xml:
    <weblogic-rdbms-bean>
    <ejb-name>VendorBean</ejb-name>
    <data-source-name>sweepDataSource</data-source-name>
    <table-map>
    <table-name>VENDOR</table-name>
    <field-map>
    <cmp-field>expIndicator</cmp-field>
    <dbms-column>VENDOR_EXP_IND</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>vendorId</cmp-field>
    <dbms-column>VENDOR_SEQ_KEY</dbms-column>
    </field-map>
    </table-map>
    <table-map>
    <table-name>VENDOR_COMMENTS</table-name>
    <field-map>
    <cmp-field>vendorId</cmp-field>
    <dbms-column>VENDOR_SEQ_KEY</dbms-column>
    </field-map>
    <field-map>
    <cmp-field>comments</cmp-field>
    <dbms-column>VENDOR_COMMENT</dbms-column>
    </field-map>
    </table-map>
    As you can see, "vendorId" is the primary key cmp field mapped toVENDOR_SEQ_KEY
    column in both tables. The relationship between the table rows are 1 to 1.When
    I run ejbc, I get the exception below:
    [ejbc] weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[Asserti
    on violated ]
    [ejbc] at weblogic.utils.Debug.assertion(Debug.java:74)
    [ejbc] atweblogic.ejb20.cmp.rdbms.RDBMSBean.processRole(RDBMSBean.java
    :1389)
    [ejbc] atweblogic.ejb20.cmp.rdbms.RDBMSBean.processDescriptors(RDBMSBe
    an.java:1105)
    [ejbc] atweblogic.ejb20.cmp.rdbms.Deployer.readTypeSpecificData(Deploy
    er.java:299)
    [ejbc] atweblogic.ejb20.persistence.PersistenceType.setTypeSpecificFil
    e(PersistenceType.java:490)
    [ejbc] atweblogic.ejb20.persistence.PersistenceType.setupDeployer(Pers
    istenceType.java:407)
    [ejbc] atweblogic.ejb20.deployer.CMPInfoImpl.setup(CMPInfoImpl.java:11
    4)
    [ejbc] atweblogic.ejb20.ejbc.EJB20CMPCompiler.generatePersistenceSourc
    es(EJB20CMPCompiler.java:64)
    [ejbc] atweblogic.ejb20.ejbc.EJBCompiler.doCompile(EJBCompiler.java:22
    3)
    [ejbc] atweblogic.ejb20.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:3
    44)
    [ejbc] at weblogic.ejbc20.runBody(ejbc20.java:470)
    [ejbc] at weblogic.utils.compiler.Tool.run(Tool.java:126)
    [ejbc] at weblogic.ejbc20.main(ejbc20.java:711)
    But if I put the "comments" <field-map> inside the VENDOR <table-map> andget
    rid off the <table-map> for VENDOR_COMMENTS, I was able to run ejbc. Ofcourse,
    I get the run time exception during deployment because, there is no columncalled
    "VENDOR_COMMENT" in VENDOR table. Please help me. Thanks a million.

  • How to create Criterian For more than one table

    Hi,
    I have one problem how to create criteria for more than one table in that using one criteria hot to get the values from database in that more than onetable for getting these values .Please send me the exampke code.
    reagrds,
    raghu

    Hi,
    I don't think its possible to create fieldcatalog for different tables,
    but if you want to do so create a dummy table which has all the fields which you want in fieldcatalog.
    populate the data from different table to that dummy table
    then create fieldcatalog for that table and pass it in the function module...
    Regards,
    Siddarth

  • Trigger for more  than One table

    Hi,
    is it possible to create a trigger for more than one table?
    I need a trigger that fires when anyone of the users updates a special value in one of the DB tables.
    this value is in about 8 or 10 tables, or must i create a trigger for each table?
    thanx
    marcel

    You would wrap the functionality required into a packaged procedure and then have a trigger on each of these tables that simply call this packaged procedure.
    Yes, you would have one trigger per table.

  • Creating SQL-Loader script for more than one table at a time

    Hi,
    I am using OMWB 2.0.2.0.0 with Oracle 8.1.7 and Sybase 11.9.
    It looks like I can create SQL-Loader scripts for all the tables
    or for one table at a time. If I want to create SQL-Loader
    scripts for 5-6 tables, I have to either create script for all
    the tables and then delete the unwanted tables or create the
    scripts for one table at a time and then merge them.
    Is there a simple way to create migration scripts for more than
    one but not all tables at a time?
    Thanks,
    Prashant Rane

    No there is no multi-select for creating SQL-Loader scripts.
    You can either create them separately or create them all and
    then discard the one you do not need.

  • Update in JDBC Sender adapter for more than one table

    Dear Friends,
              I have to select more than one table in the JDBC sender using the join condition. But i found that update statement is also mandatory in the sender comm channel. I am not going to update any flag after the select but as it is mandatory, i have decided to use the following update statement which wont effect the existing data UPDATE <tablename> set flag = ' ' where flag = ' '.
    But in my case i have 3 tables, do i need to update stmts for all the three tables.
    if yes how can i do the same.
    plz revert back i u couldnt get the queries.
    Thanks
    Prem

    HI
    UPDATE T1
    Set T1.flag =1
    where T1.columnA=value1 and T2.columnB=value2
    where T1 and T2 are tables in the same database,
    and the values (value1 and value 2 ) are provided to XI by SAP based on which the flag need to be updated in T1
    write a stored procedure specifying the join and call it in XI.
    For doing it in SQL statement only reffer to the below link ..sur you will get help .
    Multiple records update using JDBC
    Regard's
    Chetan Ahuja

  • How do u save datas more than one table using net beans ide using JSF

    Hi,
    I am new to JSF.
    I save / delete / update / New master table using POJO (Plain Old Java Objects), database - oracle and Toplink Persistence Unit.
    How do u save data more than one table using net beans ide using JSF (I am using POJO) ?
    and also Tell me the reference book for JSF.
    Thanks in advance.
    regards,
    N.P.Siva

    SivaNellai wrote:
    I am new to JSF.
    So, I am using net beans IDE 6.1 from sun microsystem. It is a free software.No, you don't drag'n'drop if you're new to JSF. Switch to source code mode. Write code manually, with the help of IDE for the speed up.
    So, please guide me the reference books, articles. I need the basic understanding of JSF, net beans IDE.[JSF: The Complete Reference|http://www.amazon.com/JavaServer-Faces-Complete-Reference/dp/0072262400] is a good book. The [JSF specification document|http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html] is also a good reading to understand what JSF is and how it works. There are also javadocs and tlddocs of Sun JSF Mojarra.

  • Master_detail for more than one record at a time

    Hi,
    How can i display master_detail records for more than one records at a time, for example, i have two tables A and B , A has username and role and B has username and profile. here i wanted to display 10 users at a time on my 6i form with username, role and profile.
    i have created a master-detail relation ship with these tables when i'm executing F8 on blcok A , it displays 10 records on BlockA but, only one at a time on block B, how can i display all corresponding records on block B at a time.
    Thanks for your help.Bcj

    Thanks Roberts, that was realy informative due to some doubts i would like to confirm my requirements , i have two blocks A and B and each master record has only one detail record. but i wanted to display at least 10 master_detail relationships(records) on the form at a time, i would like to know is it possible to do without creating any table or view for example,
    data in table A,
    username role
    AAA R1
    BBB R2
    CCC R3
    data in table B,
    username profile
    AAA P1
    BBB P2
    CCC P3
    i wanted to display it on form like below,
    username role profile
    AAA R1 P1
    BBB R2 P2
    CCC R3 P3
    Also would like to know that how can i select data from dba_users, any restriction is there on forms 6i, i can select it on sqlplus.
    Thanks Again, Bcj

  • Layout issue - More than one table sections on report?

    Hello all
    I am wondering if any of you know if there is a way to have more than one table or table field on a report.
    I'm asking this because I'd like to include a large number of fields in one report, but then that makes the report hard to read (everything is on one long line).
    I am wondering if there is a way to have more than one table section on a report so I could have the address information at the top of the report than have other additional information below the address. Basically I'm interested in making things easier to read for the user.

    Use Pivot tables to isolate the columns you want in each table in your report.
    Mike L

  • Can we use same program ID for more than one RFC scenarios

    Hi experts,
                I am working on a RFC to FILE scenario. I have created one TCP/IP connection in SM59 with a program ID. Can we use this program ID for more than one scenario. I have written code as below
    data: iquote type standard table of ZIQMD initial size 0,
          IPRODUCT type standard table of ZPMS initial size 0,
          wa_quote type ZIQMD,
          wa_PRODUCT type ZPMS.
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER'
      TABLES
        I_QUOTE       = iquote          .
    CALL FUNCTION 'Z_CBT_RFC_QUOTEMASTER' in background task DESTINATION
    'ID4'
      TABLES
        I_QUOTE       = iquote          .
      COMMIT WORK.
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER'
      TABLES
        IPRODUCT       = IPRODUCT          .
    CALL FUNCTION 'Z_CBT_RFC_PRODUCTMASTER' in background task DESTINATION
    'ID4'
      TABLES
        IPRODUCT       = IPRODUCT          .
        COMMIT WORK.
    when i am executing the code like this. i am able to send the data to 'Z_CBT_RFC_QUOTEMASTER'  , but iam not getting data  for 'Z_CBT_RFC_PRODUCTMASTER'  interface. ID4 is the connection that i have created in SM59. with program ID as ABCD.
                  Can i use the same connection for all interfaces.Please help in this, if we can use same connection for all interfaces. then how to make changes in XI.
    Thanks in advance.
    Thanks & Regards,
    Poorna.

    Just tried this and I can confirm that my earlier understanding was correct!
    One of my colleagues confused me out and the conclusion is,
    1. You need a separate TCP IP Connection for every interface with a Unique program ID.
    Regards
    Bhavesh

  • How to insert into more than one table at a time also..

    hi,
    i am a newbee.
    how to insert into more than one table at a time
    also
    how to get a autoincremented value of an id say transactionid for a particular accountid.
    pls assume table as
    transactionid accountid
    101 50
    102 30
    103 50
    104 35
    i want 102 for accountid 30 and 103 for accountid 50.
    thank u

    @blushadow,
    You can only insert into one table at a time. Take a look here :
    Re: insert into 2 tables
    @Raja,
    I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
    Insert, extract... ? Can you clarify your job ?
    Nicolas.

  • I am trying to copy more or less 30G from my MacbookPro to an external hard drive and it is stuck in the "preparing to copy" step. But that for more than one hour. What should I do to make it faster? Thanks a lot in advance!

    I am trying to copy more or less 30G from my MacbookPro to an external hard drive and it is stuck in the "preparing to copy" step. But that for more than one hour. What should I do to make it faster? Thanks a lot in advance!

    Thanks Shootist007, by blockd files I mean files that I have changed to blocked and when I tried to move then for the first time, I had to unblock again. I am trying to backup my pictures, my songs and other files like word documents and excel tables. First I put all of them as blocked, what caused the first problems on trying to move them. Then, I've unchecked the block option and if I try to move one by one, there is no problem. The issue is to move all together, because it gets stuck in the preparing to copy files step. Anyway, if I cannot do all by once, I'll do it one by one, event though that was not suposed to happen if we are talking about technology, right? Anyway, I thank you again for trying to help me!

  • Crystal Report - More than one table from MySql

    Hello, I am in need of help big time.
    I have am using Visual Studio 2010 and Crystal Report 10.
    The problem that I am incounting is that I am unable to retreive data from more than one table from a MySql database. I have been stuck on this for too long and need to hjump the hurdle.
    I am using a MySql connection string, a dataset and a crystal report which is based on the dataset.
    The main error that I am having is, the browser opens and a form appears saying "The report you requetsed requires further information" With the Server name: DataSetPropertiesDetials, while the User name and Password fields are then enabled.
    I am guessing I am missing something in my code.
    When I retreive data from one table the report is fine, but when I try to use more than one table it throws the error.
    My Code is below and also attached:
    Imports System.Data.SqlClient
    Imports System.Configuration
    Imports MySql.Data.MySqlClient
    Imports CrystalDecisions.ReportSource
    Imports CrystalDecisions.Web
    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    Public Class _Default
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim con As MySqlConnection
    Dim rpt As New CrystalReport3()
    Dim myReport As New ReportDocument
    Dim myData As New DataSet
    Dim cmd As New MySqlCommand
    Dim cmdUser, cmdProperty, cmdBranch As New MySqlCommand
    Dim daBranch, daProperty, daUser As New MySqlDataAdapter
    con = New MySqlConnection()
    'Connection String
    con.ConnectionString = "Server=****;Database=***;UID=***;Password=****"
    Try
    con.Open()
    cmdBranch.CommandText = "SELECT branch FROM tblbranch"
    cmdBranch.Connection = con
    daBranch.SelectCommand = cmdBranch
    daBranch.Fill(myData)
    cmdProperty.CommandText = "SELECT ref, keys_held, key_no, keys_out, no_name, address_line1, address_line2,key_label FROM tblproperty"
    cmdProperty.Connection = con
    daProperty.SelectCommand = cmdProperty
    daProperty.Fill(myData)
    cmdUser.CommandText = "SELECT known_name FROM tbluser"
    cmdUser.Connection = con
    daUser.SelectCommand = cmdUser
    daUser.Fill(myData)
    myReport.Load("REPORT LOCATION")
    myReport.SetDataSource(myData)
    myReport.Database.Tables(0).SetDataSource(myData.Tables(0))
    CrystalReportViewer1.ReportSource = myReport '
    Catch myerror As MySqlException
    MsgBox(myerror.Message)
    End Try
    End Sub
    End Class

    Hi, 
    You have 3 SQL commands but you are calling SetDataSource only once.  You need to look through for each of the SQL Commands. 
    Good luck,
    Brian

  • Failed to upgrade more than one table at same time

    Hi
    In Deployment Manager, I failed to upgrade more than one table at same time.
    I tried to hightlight 4 tables and set the default action as Upgrade, and click File/Generate Deploy. It passed the code generation step then I click Deploy, they are all failed with no error message.
    But they are all successful when I upgrade them one by one. Any one has any idea about this?
    For the known reason, we have no choice to do the deployment with action of 'upgrade' through OMBPlus, instead, can only do that interactively through OWB Client. I can't imagine to ask our Production side DBA to upgrade 80 tables one by one. Or I have to use the generated scripts to do the upgrade, which will resulted in 'no deploy status updated' in OWB. Any help will be very appricated.
    The version I'm using is OWB 10g.
    Thanks,
    Daming

    Hi
    First of all, Patrick's solution doesn't work for me. I didn't do cloning and there is no problem when check the WB tables.
    Second, I think your solution is only good for the developing environment just to get tables upgrade via deployment manager. In most cases, when you do a new release on PROD environment you just exp/imp the MDL file from DEV to PROD and any developing is not recommended on PROD. But your approach is trying to manually the DB, and then EDIT the mapping to do the Reconcile and then deploy. Surely you can do that if you have full control on your PROD side. However, in my situation, I have no access to the PROD for the security reason and an DBA Operator of the Client is responsible to implement my Migration process on PROD by himself.

Maybe you are looking for