1-many CMP2.0 Container Managed Persistence

Sorry for posting this again, but there did not seem to be any replies.
I have noticed a very strange phenomena in 1-many container managed relationships in the J2EESDK1.3.
In 1-many Container Managed Relationships, the J2SDKEE1.3 actually generates 3 tables rather than 2. The first table is the 1 side table. The second table is the many side table. The third table is a relation table joining the 1 side table and many side table. This relation table has 2 fields, one is the primary key of the many side table (this field becomes the primary key of the relation table) and the other field is the primary key of the one side table.
This generation of a new table for 1-many relationships is giving me a headache because these tables now form a (0 or 1) - many relationship now.
Is this defined as part of the EJB2.0 spec or is this a J2SDKEE1.3 dependant feature?

I'm afraid I can't give you an exact answer to this question, but it seems to me that this is a work-around in order not to create the relationshis in the DB.
I have noticed this behaviour as well, only I have found another problem with it. The relationship table doesn't seem to survive an undeploy or server restart. Do you have the same problem?
I think that maybe a commercial application server with a database for which it has been optimized will not show this behaviour, but will define the relationship as meta-data in the DB.

Similar Messages

  • Container Managed Persistence entity bean relationship fields

    I want to ask something that until now still confuse. Did Relationship fields in Container Managed Persistence entity beans declare , inside Database table or only Persistence fields .
    If Relationship fields not declare inside database table ,how if SQL calls the relationship fields between related entity bean.
    did container handle this task.
    example: I have 2 entity bean with CMP(Container Managed Persistence)version 2.0
    call Player and Team. every entity bean have own relationship fields and persistence fields.
    player has playerId(primary key),name,position,age persistence fields and teams is relationship fields.
    team has teamId(primary key),name,city and players is relationship fields.
    I know that all persistence fields is declare in own database table but how about relationship fields.
    can you tellme, How SQL calls can access relationship fields if relatiosnship fields is not declare in database table.
    I use J2EE RI SDK version 1.3
    and deploytool .
    thank's .

    thank's for your reply .Now I have another problem
    I use J2EE RI from java.sun .I try to follow example in j2eetutorial about CMP Example call RosterApp.ear .
    I dont'change anything code inside RosterApp.ear but when I deploy and runclient command thereis syntax error :
    java.rmi.ServerException: Remote exception occured in server thread :nested exception is java.rmi.ServerException :exception thrown from bean :nested exception is : java.ejb.EJBException :nested exception is :java.sql.SQLException :syntax error or access violation ,message from server: "you have an error in SQL syntax near "
    "leagueBeanTable" WHERE "leagueId" = 'L1' at line 1
    in example ,RosterApp.ear use Cloudscape database ,but I try to use Mysql database for RosterApp.ear ,is there any different syntax SQL from Cloudscape to Mysql .
    if like that ,so I must edit first SQL calls from Cloudscape to MYSQL . I think because relationship fields is for entity beans only ,so how if mysql database want to access foreign key another table because foreign key isn't declare in databse table.
    example : I have 3 entity bean call player, team, league .
    1. PlayerEJB have persistence fields name, position, playerId(primary key), cmr fields is teams
    2. TeamEJB have persistence fields name, city, teamId (primary key) , cmr fields is players and leagues .
    3. LeagueEJB have persistence fields name ,sport, leagueId(primary key), cmr fields is teams
    so table is
    PlayerEJB <--->TeamEJB<--->LeagueEJB
    Player have some finder method call findBySport(String Sport) .
    because Sport is persistence fields for LeagueEJB
    so PlayerEJB must traverse TeamEJB first before LeagueEJB
    EJB QL : SELECT distinct object(p) FROM Player (p) IN (p.teams) AS t
    WHERE t.league.sport = ?1
    I know that Container will translates EJB QL to SQL calls ,but default is only for cloudscape database and I use for MYsql .
    so can you helpme how to query method findBySport(String sport) to Mysql calls .
    thereis no foreign key between table in database table there is only Relationship fields in entity bean.

  • Bean-Managed vs. Container-Managed Persistence

    Hello,
    I would like the real world skinny on bean-managed persistence vs. container-managed persistence. I have heard the bean-managed offers higher scalability and performance, while container-managed offers simplicity but with a cost. Can someone give me some perspective?
    Thanks,
    Rob Miller

    Wrong forum, but I guess if you are new to java it could be argued that anything goes...
    General rule:
    use CMP if you don't have worries about speed or legacy systems.
    use BMP if you need to control the persistence and/or want to connect to legacy host systems. BMP allows you to set up caching and transaction handlers to handle the presistence in a manner more suited to your needs.

  • Bean or Container Managed Persistence

    Hi,
    I've been reading up on the Sun J2EE tutorial. One of the topics there is bean or container managed persistence. It states that container managed is easier for developers and allows for more portability. The class codes are much smaller compared to bean managed and developers need not worry about database queries.
    Can anyone share their experiences on this? Any 'Real World' advantages and disadvantages? Is there a guideline I can follow when to use bean or container managed persistence?
    Thanks,
    -Ray

    That seems like an obvious flaw. So why was it even considered in the
    J2EE framework? I mean wouldn't the J2EE architects immediately realize
    that? Just doesn't make sense to me why there's even a tutorial or books
    for it. What does it suppose to solve then??I know what you mean... again, I think they thought it looked good on paper.
    And it gets worse...
    Before you use Entity Beans you must be absolutely sure that there will never be another app that accesses the underlying table that doesnt use the EntityBean to do it... For example a C++ App that accesses the tables directly... otherwise you have to set a flag in the App Server that states that basically every time a property on an EntityBean is read the Bean will have to RE-READ the beans state from the database!!
    Some things look really good, from an OO perspective, but dont work really well in reality. Sure Entity Beans look really good in the example program in the tutorial, but what happens when you multiply the number of entity beans by 1000, 100,000, or more? Just think of the CPU, and Memory overhead for instantiating all those objects!
    There are people out there who believe that using Stored Procedures is a no-no because in their minds it puts "Business Logic" on the database and not the App Server...To this I say... BUNK... Ive seen several instances where by simply moving a set of queries from the App Server to a stored procedure on the database, allowed for a 10-20 times performance gain because of the elimination of network IO. In one instance I saw a query go from 3 hours execution time on the App Server to under 10 minutes on the database... But stored procedures arent OO...
    So IMHO before you use EntityBeans at all... be absolutely sure you understand all of the ins-and-outs of doing so.

  • Container-managed persistence Entity bean

    WE use a container-managed persistence Entity bean. To handle the state synchronization between the object & the database, what must WE do?
    Thanks in Advance

    That's the container's job. You can use the commit option A/B/C to control how the DB and objects are synchronized.
    -Scott
    http://www.swiftradius.com

  • Container-managed persistence application problem

    I worked out a container-manager persistence entity bean application. Everything is fine until I run the client. When I ran the client, I got the following exception from the server side when I turned on "j2ee -verbose":
    "Exception in thread "RequestProcessor[20]" org.omg.CORBA.BAD_PARAM: CourseBean_P
    M_EJBLocalObjectImpl minor code: 1330446342 completed: Maybe
    at com.sun.corba.ee.internal.orbutil.ORBUtility.throwNotSerializableForC
    orba(ORBUtility.java:660)
    at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_abstract_int
    erface(CDROutputStream_1_0.java:631)
    at com.sun.corba.ee.internal.iiop.CDROutputStream.write_abstract_interfa
    ce(CDROutputStream.java:281)
    at com.sun.corba.ee.internal.javax.rmi.CORBA.Util.writeAbstractObject(Ut
    il.java:145)
    at javax.rmi.CORBA.Util.writeAbstractObject(Util.java:128)
    at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectDelegate(IIO
    POutputStream.java:99)
    at com.sun.corba.se.internal.io.IIOPOutputStream.writeObjectOverride(IIO
    POutputStream.java:106)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:271)
    at java.util.ArrayList.writeObject(ArrayList.java:513)
    at com.sun.corba.se.internal.io.IIOPOutputStream.writeObject(Native Meth
    od)
    at com.sun.corba.se.internal.io.IIOPOutputStream.invokeObjectWriter(IIOP
    OutputStream.java:525)
    at com.sun.corba.se.internal.io.IIOPOutputStream.outputObject(IIOPOutput
    Stream.java:492)
    at com.sun.corba.se.internal.io.IIOPOutputStream.simpleWriteObject(IIOPO
    utputStream.java:125)
    at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValueInternal(Valu
    eHandlerImpl.java:134)
    at com.sun.corba.se.internal.io.ValueHandlerImpl.writeValue(ValueHandler
    Impl.java:114)
    at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROut
    putStream_1_0.java:1049)
    at com.sun.corba.ee.internal.iiop.CDROutputStream_1_0.write_value(CDROut
    putStream_1_0.java:638)
    at com.sun.corba.ee.internal.iiop.CDROutputStream.write_value(CDROutputS
    tream.java:268)
    at _RegisterBean_EJBObjectImpl_Tie._invoke(Unknown Source)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(Ge
    nericPOAServerSC.java:519)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(Gen
    ericPOAServerSC.java:204)
    at com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAS
    erverSC.java:112)
    at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:273)
    at com.sun.corba.ee.internal.iiop.RequestProcessor.process(RequestProces
    sor.java:84)
    at com.sun.corba.ee.internal.orbutil.ThreadPool$PooledThread.run(ThreadP
    ool.java:99)
    Anybody has any insight in this. I checked the appliation using the verification tool, it shows no problem at all. I am really out of idea!
    Thanks a lot!

    send me your contact info and i think i can help.
    my email is : [email protected]
    In addition I believe ssniazi is in violation of the conduct code of this website because ssniazi is requesting information which will be used by a business entity without telling the users that it will be used in that way. And I expect that Oracle itself would frown on such activities.
    2.3 You agree that You will not use the Website to:...(g) collect or store personal data about other users unless specifically authorized by such users.

  • Extreamly slow container managed persistence

    Hi.
    We perform the following procedure:
    1. We invoke a finder method on a container managed bean
    2. Then we traverse the enumeration of beans returned and invoke a getter
    method to get their properties.
    The finder finishes really fast, but then traversing the enumeration takes
    about 1 second per entity bean.
    Any suggestions?
    Giora Katz-Lichtenstein

    Hi,
    When you're iterating through your collection or enumeration of primary
    keys, each method call is going to the database to retrieve the row
    associated with that primary key. I'll bet the issue is with the calls to
    the db or whatever persistent store you're using.
    Steve...
    Giora <[email protected]> wrote in message
    news:82kolv$192$[email protected]..
    Hi.
    We perform the following procedure:
    1. We invoke a finder method on a container managed bean
    2. Then we traverse the enumeration of beans returned and invoke agetter
    method to get their properties.
    The finder finishes really fast, but then traversing the enumeration takes
    about 1 second per entity bean.
    Any suggestions?
    Giora Katz-Lichtenstein

  • Accessing collection field in container managed persistence bean

    Hello!
    How can i get 1:m relatioship, collection fields value?
    What is the purpose of ejbSelect-method, in bean business class?

    Please ask your EJB questions within the Enterprise JavaBeans section of this forum.
    The ejbSelect Method is a query method (like the finder mehtod) but it is not directly exposed to the client in the home interfacce or component interface. Rather, ejbSelect() is used internally within an entity bean as a helper method to accesss a storage. ejbSelect() is useful when you have entity beans in relationships with external data, such as other entity beans.
    look at http://www.theserverside.com/articles/content/ApplyingEJB/matena8.pdf for an example

  • Container managed persistence

    Hi!
    I'm trying to figure out how CMP works with IPlanet but haven't found any
    examples. I would need to know where to define the table names that my
    entity beans use?
    Sebastian

    Hi Seb,
    Please find the attached file .....will help u
    Ananthram
    "Sebastian Lofhjelm" wrote:
    Hi!
    I'm trying to figure out how CMP works with IPlanet but haven't found any
    examples. I would need to know where to define the table names that my
    entity beans use?
    Sebastian

  • How to add a finder method in the container manager Bean in the weblogic6.1

    in the environment jbuilder6 andweblogic6.1,use container manager entity Bean,it can automatic generate the findAll() method,I want to add a new method to find an element in the home interface,such as findByName(),name is a element of a table of the database.in the weblogic-cmp-rdbms-jar.xml,this is part of the fiile:
    <finder>
    <finder-name>findAll</finder-name>
    <finder-query><![CDATA[ (= 1 1) ]]></finder-query>
    </finder>
    <finder>
    <finder-name>findByName</finder-name>
    <finder-param>java.lang.String</finder-param>
    <finder-query><![CDATA[ (=name $name) ]]></finder-query>
    </finder>
    It can successfully compile the findAll(),but it is wrong when compile the findByName(),as follows
    "www.ejbgrpx": Method Name: findByName
    "www.ejbgrpx": Invalid specifications for a WebLogic RDBMS CMP EJB.
    "www.ejbgrpx": ERROR: Error from ejbc: weblogic.ejb20.cmp11.rdbms.finders.IllegalExpressionException:
    "www.ejbgrpx": While trying to process Finder
    "www.ejbgrpx": Parameter Types: (java.lang.String)
    "www.ejbgrpx": WebLogic Query: (= name $name)
    "www.ejbgrpx": Finder Expressions: ()
    "www.ejbgrpx": Could not parse WLQL expression: (= name $name) null
    "www.ejbgrpx": ERROR: ejbc found errors
    thank you

    The finder methods that you are referring to are only simple finder methods. If you would like to add specialized finder methods, you can make your entity bean with bean managed persistence and not container managed. If you are using EJB 2.0, your entity bean with container managed persistence can use EJB QL for finder methods. You can search for this topic and/or download the EJB 2.0 specifications
    Hope this helps

  • Finder method in container-managed entity bean

    Finder method of a container entity bean is taking the primary key class object of another entity bean. How to map this in the xml descriptor file weblogic-cmp-rdbms.xml for this type of beans.
    I am trying to deploy the jasmine computer store of Mastering EJB by EdRoman.
    I couldn't write the deployment file weblogic-cmp-rdbms.xml for Order Entity bean which uses CustomerPK as an argument in its finder method.
    Please tell me how to write this. I am trying on weblogic 5.1
    Thanx in advance
    Srivatsa

    hello,
    in container managed persistence, you specify on your xml file the name of your table. so the primary key you want to use have to be a foreign key in your table. otherwise i don't think that you can use a container managed persistence.
    Najib.

  • Container Managed Entity Beans and Client Identifier in Oracle

    Is it possible to use Container Managed Entity Beans (EJB with CMP)
    in a way that the Oracle database sessions still know the
    individual Client Identifiers of the actual users
    (not just the Identifier of the proxy user defined in the
    Connection Pool)?
    If Yes: How?
    If No: The consequence would be that the
    technologies EJB with CMP cannot be user together with
    Oracle Virtual Private Databases (VPN) because VPN requires
    some kind of Client Identifier.
    I am grateful for any hint.
    Regards,
    Martin Siepmann
    +49 (0)163 / 7765328

    Not quite an auto-incrementing PK, but it is managed by the container. the following is from the turorial
    Generating Primary Key Values
    For some entity beans, the value of a primary key has a meaning for the business entity. For example, in an entity bean that represents a phone call to a support center, the primary key might include a time stamp that indicates when the call was received. But for other beans, the key's value is arbitrary--provided that it's unique. With container-managed persistence, these key values can be generated automatically by the EJB container. To take advantage of this feature, an entity bean must meet these requirements:
    * In the deployment descriptor, the primary key class is defined as a java.lang.Object. The primary key field is not specified.
    * In the home interface, the argument of the findByPrimaryKey method must be a java.lang.Object.
    * In the entity bean class, the return type of the ejbCreate method must be a java.lang.Object.
    In these entity beans, the primary key values are in an internal field that only the EJB container can access. You cannot associate the primary key with a persistent field or any other instance variable. However, you can fetch the bean's primary key by invoking the getPrimaryKey method, and you can locate the bean by invoking its findByPrimaryKey method.
    Maybe that is good enough
    christina

  • Container managed persistance: many-many relationship

    Here's the scenario:
    table STUDENTS has columns ID, NAME
    table CLASSES has columns ID, TITLE
    table STUDENT_CLASSES is an intersection table with columns STUDENT, CLASS which are foreign keys to the ID columns in the STUDENTS and CLASSES tables
    How do I specify to OC4J that it should use the STUDENT_CLASSES table to facilitate the container managed many-many relationship?

    Voytek -- I would use the ormap demo (projects to emps relationship) as an example and see what exists from deploying that. I've included the original ejb-jar.xml entry as well as a trimmed down version of the orion-ejb-jar.xml entry. In this case it is the default mapping but what you would need to do is include an orion-ejb-jar.xml with just the parts you want to control.
    <ejb-relation>
    <ejb-relation-name>Emps-Projects</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Projects-have-Emps</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>ProjectBean</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>employees</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>Emps-have-Projects</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>EmpBean</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>projects</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    <entity-deployment name="ProjectBean" location="ProjectBean" table="ProjectBean" >
    <primkey-mapping>
    <cmp-field-mapping name="projectNo" persistence-name="projectNo" />
    </primkey-mapping>
    <cmp-field-mapping name="projectName" persistence-name="projectName" />
    <cmp-field-mapping name="employees">
    <collection-mapping table="EmpBean_projects_Proje__296v53">
    <primkey-mapping>
    <cmp-field-mapping name="ProjectBean_projectNo">
    <entity-ref home="ProjectBean">
    <cmp-field-mapping name="ProjectBean_projectNo" persistence-name="ProjectBean_projectNo" />
    </entity-ref>
    </cmp-field-mapping>
    </primkey-mapping>
    <value-mapping type="hr.EmpLocal">
    <cmp-field-mapping name="EmpBean_empNo">
    <entity-ref home="EmpBean">
    <cmp-field-mapping name="EmpBean_empNo" persistence-name="EmpBean_empNo" />
    </entity-ref>
    </cmp-field-mapping>
    </value-mapping>
    </collection-mapping>
    </cmp-field-mapping>
    ... finder methods removed ...
    </entity-deployment>
    I hope this helps -- Jeff

  • Container managed bean persistence queries

    Hi,
    I want to know where the container generated java sources and
    classes for the container managed beans will be sotred as i want
    to look out the sql queries that is not inserting and updating
    the values into the tables.
    As well i want to refer how the bean persistence is handled.
    thanks
    kumar

    Hi,
    I want to know where the container generated java sources and
    classes for the container managed beans will be sotred as i want
    to look out the sql queries that is not inserting and updating
    the values into the tables.
    As well i want to refer how the bean persistence is handled.
    thanks
    kumar

  • Problem with non-container managed entity manager

    i am working on a project, in which i am using entity beans.i use netbeans, glassfish as application server and toplink as persistence provider .
    i created a java class that handles all the operations with the entitys, which means i using non-container managed entity manager.
    in the constructor
    try{
                EntityManagerFactory emf = Persistence.createEntityManagerFactory("voidPU");
                entityManager = emf.createEntityManager();
            catch(Exception ex){
                throw new EJBException(ex.getMessage());
            }then i call a function in this class from a servlet
    the code of the function
    List users = null;
            try {
                ProgLanguages progLanguage = entityManager.find(ProgLanguages.class, languageId);
                users = (List) progLanguage.getUserIdCollection();
            catch(IllegalStateException illegalStateException){
                throw new EJBException(illegalStateException.getMessage());
            catch(IllegalArgumentException illegalArgumentException) {
                throw new EJBException(illegalArgumentException.getMessage());
            }i got an IllegalArgumentException saying Unknown entity bean class: class vanguard.server.entity.ProgLanguages, please verify that this class has been marked with the @Entity annotation
    what confuses me is that sometimes it works and most of the time it does not work, have i made anything wrong?, or there is a problem with any of the tools netbeans, glassfish, or toplink?

    Is it always the same entity that is reported as 'unknown' ? You mention that it works sometimes but is it the same deployment and the same code that works? The first thing I would verify is that the ear is being created as expected by netbeans. Check the persistence.xml file and verify that all of the classes are listed that will be used as entities.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for

  • How can I create and organize a symbol to be integrated into Illustrator's stock symbols?

    Hello, I am trying to create a series of symbols for maps (north arrows, scale bars, etc.) and then save them in Illustrator's "stock" symbol libraries - such as "maps".  The goal is that whenever I create a new Illustrator file, I can immediately gr

  • Order of tracks in a playlist

    I used to be able to re-arrange tracks in a playlist by dragging them - I now can't - they just won't move! Please help

  • Error code is 2738...help please asap, anyone?

    When I try to install iTunes v7, i get the error code is 2738 message. I tried doing what apple and others said to do to fix this problem and nothing has worked. When i try to register VBscript i get a message that says it failed return code was: 0x8

  • Photoshop CC layered files preview

    Hey guys I'm having alot of issues with thumbnail previews in Finder ever since I updated to Mavericks. Basically, any TIF-files that include layer masks won't show a preview at all in Finder. I just get the static TIF-file graphics, but no actual pr

  • Does the warranty for the iPod nano 7 cover a washing machine accident?

    About a week ago, I left my almost new ipod nano 7 in one of my jeans pockets. My sister thought the jeans were dirty and did not hesitate or check the pockets before throwing them in the washing machine. I later got a call from her that she had foun