Jdev 9.0.3 and CMP/CMR entity beans.

Hi,
I'm using Jdev 9.0.3 to generate CMP/CMR entity beans.
I generate them from a database (oracle).
After the generation the code doesn't even compile.
Is there any issue with Jdev 9.0.3 generating CMP/CMR EB ?
I'm also using compound primary keys. Would this matter ?
Thanks.
giuseppe.

PUSH.

Similar Messages

  • Somehow ejbCreate method of an Entity EJB is not inserting a record into the database. I'm using BMP and calling the Entity bean method from a servlet. I'm using NAS 4.0 sp5 on Win 2k.

    Also if I call the insert query from within the servlet it works fine. I have disabled global transactions. Am I missing something out ? Please
    any help would be greatly appreciated.

    May be your servlet is not able to lookup the EJB. You can use some print statements and see whether lookup ok or not.
    Just a guess.
    Plese get back, if any queries.
    Thanks,
    Rakesh.

  • CMP entity bean update after database update

    I'm new to JDeveloper and J2EE. Since JDev 10.1.3 is now production software I finally got started with it. Everything was quite simple to achieve however I have one problem.
    My current setup is faily easy. I have a statelss session bean and a CMP entity bean using TopLink (both EJB 2.1). Getting them both created went smooth and having the two talk was as easy as pie thanks to Jdev.
    The problem I have is with the entity bean. I'm using a custom finder method to retrieve records using non-PK fields. This works like a charm and I'm getting the data I need. But when I update the data in the database (OracleXE) and I rerun the client I get the old data. The only way for me to get new data is to restart the embedded OC4J server in JDev.
    How can I have the entity bean updated by changes in the database?

    Thanks Avi!
    I spent some time with the documentation and I see I can configure the cache. However how to do this is not clear to me. I have the impression that most of it relates to BMP entity beans.
    Apparantly there is a DoNotCheckCache method I can invoke on the query, but I have no idea how to achieve this...
    Message was edited by:
    Deddiekoel

  • 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.

  • Nested EJB QL Query in Entity Bean

    Hi All
    We are using CMP based Entity bean which has name <i>EmployeeBean</i> with a field pSALARY. We want a finder method which return an employee with maximum salary. we are using following Query.
    <b>select object(b) from EmployeeBean  b  where
                        b.pSALARY = (select max(c.pSALARY)  from EmployeeBean c)</b>
    But we validate the query in NWDS but we get following error
    <b>EJB QL statement is invalid. See General User Output View for details.</b>
    General User output view is blank. so we could not analyze the error in this query.
    can anybody tell us what's wrong with this Query. Or else how we should formulate the query in another way so that it gives us required result.
    Thanks in Advance

    Hi
    just try  like this...
    MAX() and MIN() can be used to find the largest or smallest value in a collection of any type of CMP field. It cannot be used with identifiers or paths that terminate in a CMR field. The result type will be the type of CMP field that is being evaluated. For example, the following query returns the highest amount paid for a Job.
    <b>SELECT MAX( job.pSALARY )
    FROM EmployeeBean AS c, IN (c.EmployeeBean) AS job</b>
    The MAX() and MIN() functions can be applied to any valid CMP value including primitive types, strings, and even serializable objects. As you may recall, a CMP field can be a serializable application object that is converted to a binary field and stored in a database. The result of applying the MAX() and MIN() functions to serializable objects is not specified, however, because there is no standardized way of determining which serializable object is greater than another.
    The result of applying the MAX() and MIN() functions to a String is type depends on the underlying data store used. This uncertainty results from problems inherent in String comparisons, which are addressed fully in the section "The Problems with Strings."
    just refer this link also..
    http://www.theserverside.com/articles/article.tss?l=MonsonHaefel-Column5
    Regards
    Kishor Gopinathan

  • Urgent!Poor performance in Entity beans

    we're using Weblogic 5.1, Oracle 8i.(both installed in Solaris 5.8) We
    found that the performance of our entity beans is poor, the reason we
    guess is because when we issue a select statement, the jdbc, at the same
    time, issue a update statement, that's why the response time is slow.
    (By the way,we use oracle thin driver to connect.)
    I know we can set autocommit to false but our beans are cmp,so we can't
    set properties in connection pool.What can we do then?Can we set any
    transaction attributes in our ejb,so we can solve our problem?
    Thx!
    Pete

    A few issues with the linked article:
    " 1. Where ever possible, using Entity bean with CMP over Entity bean with BMP, will ensure increase in performance... Tuned CMP entity beans offer better performance than BMP entity beans."
    Bull. Every time I have seen some statement like the above it has never contained any associated proof nor explaination of how a container vendor's code can interact with a DB any better than mine.
    The only means by which a container vendor can generically improve the performance of DB interactivity is to not do it, namely by caching the data and monitoring modification. This is rarely used due to mitigating factors such as any case where the container does not have sole access and omniscience over the DB.
    "Moving towards the CMP based approach provides database independence since it does not contain any database storage APIs within it."
    Ahh yes, lets trade in EJB container independence for database independence. It's interesting that the biggest proponents of CMP (and the ones who pushed it into the spec) are the biggest container vendors. Database storage APIs??? Perhaps JDBC and "select * from USER where..." are somehow viewed as database specific.

  • Reduce entity beans pverhead

    this is rather a j2ee question not a weblogic one
    i am working on an application: we are at a point where we are thinking WHY are we using entity BMP beans:
    if we are doiNG 1200 transactions or changing 1200 tables that would be a huge overhead /overload on the ejb container
    we would have 1200 entity beans instances..
    in our case we cannot use CMP as our application should not be dependent on a one single type of container: looking at this what is it that entity beans offer that we should use them in the first place : i am a little confused at this point but want to see my options thanks
    kinda looking at merits and demerits of entity beans here

    There is not enough room to give a complete description here, but in general, if you use CMP you can gain from many techniques that are built into the CMP container to optimize the work done per trip to the Database per transaction, thus giving you a improved performance. As you mention, many of these types of improvements are not specified in the EJB spec, however some of these improvements, such as 'Relationship Caching', are now present in many CMP containers. 'Relationship Caching', which will retreive a parent bean and it's children (and their children, etc) all in a single database query, can save an application a lot of extra database trips which would be spent retreiving the children. There are some features, such as operation ordering, that one can get using WebLogic without having to rely on setting a platform specific deployment descriptor element, it is on by default in v 8.1. Of course if you migrate to another platform you will lose the performance gain, but you will not have to recode any of your application to migrate.
    Operation ordering will 'buffer up' all of your Database INSERTS, UPDATES and DELETES and do them all when the Transaction COMMITs. An INSERT followed by an UPDATE on the same bean will be submitted as a single INSERT of the latest state of the bean, thus saving a separate UPDATE after the INSERT. If your JDBC Driver supports batched operations on prepared statements, this can be the source of another performance gain when used on top of operation ordering, this essentially reduces the traffic to the database to achieve the same amount of work.
    Optimizations such as these would be tedious to code manually but the CMP container will do them for you automatically.
    This is just a small sample of what's available to give you an idea for starters...
    -thorick

  • Merge ejb Jar containing entity beans

    Hi,
    Is there a way I can merge two or more jar files which contain Entity beans, I
    am
    deploying under WAS 6.1 and am developing under Jbuilder 6??? I am using CMP
    2 entity beans
    Thanks In Advance

    Hi.
    Try posting this to the ejb newsgroup.
    Regards,
    Michael
    jack V wrote:
    Hi,
    Is there a way I can merge two or more jar files which contain Entity beans, I
    am
    deploying under WAS 6.1 and am developing under Jbuilder 6??? I am using CMP
    2 entity beans
    Thanks In Advance--
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Entity beans(EJB 3.0) replication in IAS 10.1.3

    Hi,
    I have a application with webservices, having a few stateless session beans and a few entity beans. The application has to be deployed in a grid environment, on 2 machines.
    My problem is that a change in an entity needs to be replicated on both machines. Right now, with the application deployed on 2 machines, in a load balanced non-cluster environment, I have stale data. I have reviewed the option of cache coordination, but the toplink essentials don't have this feature.
    As a temp solution, one of the machines was stopped. Another option is to disable the entity beans cache completely, but that's not what I'm looking for.
    I have done some digging in the documentation, and it's clear that stateful beans can be replicated in a clustered environment. In this configuration, are the entity beans replicated too?

    Thanks for your reply. I'm actually interested in the entities, not the web session. I need to make sure that the entities cache stays synchronized between the nodes.
    Example:
    I have entity "customer" for example.. I do an update from one of the nodes, changing the customer name, and do commit. This happens in node 1. I want to make sure that the node 2 knows this happened.

  • Object locking of entity bean in a SSBean[Environment: WebLogic 10.0, EJB3.0, Kodo/OpenJPA]

    Hello friends,
    I am facing bottle neck with Object Locking for an Entity bean using OpenJPA Persistence Manager under Weblogic 10.0 application server deployments.
    I want to block [ for the specific method ] entity bean being accessed from other client programs when they invoke common method in a Stateless Session EJB. Particularly, Consider the situation:
    Client1: Modifying Customer entity with id: 100. Then I locked that entity using OpenJPA Entity Manager within the transaction block. And i entered that thread to sleep before committing the transaction.
    At this time, started new thread, Client2: Modifying the same Customer entity with id:100. I expected this thread will be get blocked when control pass to the lock() method. But it doesn't happened. It goes through the line of codes and also put into sleep.
    After thread sleep timeout, first thread Client1 commit successfully. But the second gets Rollback Exception due to optimistic lock exception occurring since customer entity is modified in another transaction.
    This exception is occurred because of Database level concurrency control for optimistic locking in a weblogic server. Its default to weblogic.
    But, what i expected is to assert lock at the object level, thereby the 2nd thread - Client2 will be blocked while Client1 is in the middle of a transaction and then Client2 use modified Customer entity . But it doesn't happened. I used Kodo Persistance Provider as Persistence Unit, OpenJPAEntityManager to do transaction, locking , finding and merging the entity bean.
    Can anyone provide help to fine grain this object locking functionality ??? I look forward to your brilliant thoughts......
    Rajesh KR
    Geojit Technologies

    Dear Chicon,
    I made thread to sleep for checking the "Object Locking" functionality of OpenJPAEntityManager. My intention was to block the second thread when the first thread being locked when a concurrent access occurs. But it doesn't happened and code execution passed to thread sleep.
    I mean when 2 client access the same entity at same time (in same milliseconds) , and what happens to 2nd thread when 1st thread locks the entity object.
    I guarantee you that i started the 2nd thread before the 4sec time stamp given to the object locking. I tested it with a bigger timestamp, still it given concurrent blocking of the same entity bean.
    My question is why the object locking is not working with concurrent access to same entity bean from more than one thread???
    I think you get the correct question what i intended ????
    Regards,
    Raj...

  • Transactions entity bean

    We have a rather large system where we get a lot of transactions. To
    tune our system we decided to turn off transaction support for some
    beans. (by setting the transaction attribute to NotSupported).
    The system did not decrease the amount of transactions run so we
    started wondering what was going on.
    To test this we first implemented a small test application and then
    also tested some examples provided by weblogic. In both cases we came
    to the conclusion that when using entity beans transactions are always
    run. We tested with wl6.1 and wl6.1sp3
    A short example of some code:
    Client:
    for (int i=0; i<numBeans; i++) {
    accounts = findOrCreateAccount("ID: "+i, i * 1000);
    //transfer 1000 from account 10 to account 11
    try {
    accounts[10].withdraw(1000);
    accounts[11].deposit(1000);
    } catch (ProcessingErrorException e) {
    log(" could not xfer cash");
    } catch (RemoteException e) {
    log(" could not xfer cash");
    AccountBean (Entity Bean)
    public double deposit(double amount) {
    log("Depositing $" + amount + " into '" + accountId + "'");
    if (weblogic.transaction.TxHelper.getTransaction() == null) {
    log("dep no transaction");
    else {
    log("dep tx:
    "+weblogic.transaction.TxHelper.getTransaction().getXID());
    balance += amount;
    if(true) {
    log("throwing EJB EXCEPTION FOR TESTING");
    throw new EJBException();
    return balance;
    ejb-jar.xml
    <container-transaction>
    <method>
    <ejb-name>beanManaged</ejb-name>
         <method-intf>Remote</method-intf>
         <method-name>deposit</method-name>
    </method>
    <method>
    <ejb-name>beanManaged</ejb-name>
         <method-intf>Remote</method-intf>
         <method-name>withdraw</method-name>
    </method>
    <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
    The first indication that a transaction was running was to check the
    log:
    deposit transaction: 370:971b99c458e3d95b
    Then the transaction was rolled back and and we could see that the
    account balance was unchanged which proves that a transaction was
    running.
    We can't be the first ones to discover this, but I can't find this
    documented anywhere else.

    If an entity bean is called and no transaction is in effect, the container
    will
    always start a transaction for its own use. Its not expensive to start a
    transaction in WLS. The best architecture is almost always to
    begin/commit
    transactions before calling entity beans and let the entity beans inherit
    the transaction, so that multiple calls to an entity bean are grouped into
    a single transaction.
    Seth
    Daniel Bernholc wrote:
    We have a rather large system where we get a lot of transactions. To
    tune our system we decided to turn off transaction support for some
    beans. (by setting the transaction attribute to NotSupported).
    The system did not decrease the amount of transactions run so we
    started wondering what was going on.
    To test this we first implemented a small test application and then
    also tested some examples provided by weblogic. In both cases we came
    to the conclusion that when using entity beans transactions are always
    run. We tested with wl6.1 and wl6.1sp3
    A short example of some code:
    Client:
    for (int i=0; i<numBeans; i++) {
    accounts = findOrCreateAccount("ID: "+i, i * 1000);
    //transfer 1000 from account 10 to account 11
    try {
    accounts[10].withdraw(1000);
    accounts[11].deposit(1000);
    } catch (ProcessingErrorException e) {
    log(" could not xfer cash");
    } catch (RemoteException e) {
    log(" could not xfer cash");
    AccountBean (Entity Bean)
    public double deposit(double amount) {
    log("Depositing $" + amount + " into '" + accountId + "'");
    if (weblogic.transaction.TxHelper.getTransaction() == null) {
    log("dep no transaction");
    else {
    log("dep tx:
    "+weblogic.transaction.TxHelper.getTransaction().getXID());
    balance += amount;
    if(true) {
    log("throwing EJB EXCEPTION FOR TESTING");
    throw new EJBException();
    return balance;
    ejb-jar.xml
    <container-transaction>
    <method>
    <ejb-name>beanManaged</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>deposit</method-name>
    </method>
    <method>
    <ejb-name>beanManaged</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>withdraw</method-name>
    </method>
    <trans-attribute>NotSupported</trans-attribute>
    </container-transaction>
    The first indication that a transaction was running was to check the
    log:
    deposit transaction: 370:971b99c458e3d95b
    Then the transaction was rolled back and and we could see that the
    account balance was unchanged which proves that a transaction was
    running.
    We can't be the first ones to discover this, but I can't find this
    documented anywhere else.

  • Entity Bean Performace

    How well do Entity beans perform as opposed to using stateless session
    beans for doing all database access? I've never woked with them before
    and it seems like there is a lot of over-head involved. The database we
    are using will be shared by other systems, so even cached entity beans
    will have to hit the database to make sure they don't have stale data.
    Are there other benifits I'm missing?
    -Nathan

    It's altogether a different concept in EJB3 it's more of a JPA and not exactly Entity Beans.

  • Entity Beans not getting garbage collected

    Hi,
    I am developing an application that is using EJBs utilizing several common design patterns (i.e. Session Facade, DAO, and Fast Lane Reader). All of the patterns used have come from books by Sun Microsystems Press.
    As I have understood the pattern, the Session Facade pattern uses Stateless Session Beans (SLSB) to implement a desired functionality and accesses the entity beans locally. The results from the entity beans are placed into Value Objects and passed back to the client separating any direct access with the entity beans from the client. In my case, I am using BMP for my entity beans.
    The problem I am seeing with Optimizeit is that none of my entity beans are getting garbage collected despite no references to them. The SLSB creates what entities it needs to perform a task at the local level, puts the data into a value object and goes out of scope.
    Shouldn't the entity beans get removed if the object that references them has gone away or am I missing something?
    Is there a proper way to set an entity bean (or any EJB for that matter) for garbage collection.
    thanks in advance for any help...

    You might even discover that entity beans can get created even before you use them.
    Your application server creates "pools" of bean instances that it can use when it needs to. It is part of this role, and is done in order to optimize performances.
    You cannot force them to be garbage collected. Even if you stop referencing them, the app server will.
    When your create references to a bean, it (usually) won't create an instance. It will take an existing one, and load data into it, using ejbCreate or ejbActivate.
    Hope this helps.
    /Stephane

  • CMP entity beans from tables in 9.0.3 jdev preview

    I am trying to generate CMP entity beans from oracle tables using 9.0.3 jdeveloper preview. My oracle db version is 9.2. I notice that if a table has a single column primary key, no xxxPK.java file is created. However, if the primary key is multi-column an xxxPK.java file is created. Is this correct behavior? I expected an xxxPK.java file to be created regardless of the number of columns in the primary key for the table. Has anyone else noticed this? I am new to EJB so forgive my ignorance.

    Comparing to JDev 902, I think this is a much better decision. Having to change beans with a single field PK to not using a custon PK class, to avoid using that class was a pain in JDev 902. There4s little benefit in using a custom class when there4s only a single field in it... some will say that it prevents having to do majot changes to your code if the PK changes in the future and add another field. But a careful database design will void this almost completely. So having JDev 903 use a java native class is a better option in this situation. At least from my personal point of view.

  • Is CMR methods necessary in CMP Entity Beans?

    I refer to the J2EE 1.3.1 SDK CMP Customer application sample.
    I looked thru the CMP sample source code from the J2EE 1.3.1 SDK under /j2sdkee1.3.1/doc/sample and found that for every relationship the CustomerBean has with another Bean, there has to be some CMR methods.
    In this case, Customer has a:
    public abstract void addAddress(LocalAddress address)
    public abstract void addSubscription(LocalAddress)
    For the other That I understand. It's like specifying the foreign key for the record, so to speak.
    So for every foreign key field in other Beans (tables), does CustomerBean need a CMR method (get/set)? So if CustomerBean has 20 other tables using the CustomerID as a foreign key, does that imply that CustomerBean will have at least 20 CMR methods so that other Beans can add themselves and connect to CustomerBean?
    Another thing I noticed is that for Beans with foreign key(s) (sorry for including database terms, perhaps just called reference now in J2EE), they all link up to the other Beans (tables) in ejbPostCreate by adding themselves to the Bean Collection.

    IMHO you don't have to map every relationship
    (at DB level) when you declare CMR fields
    at EJB level.
    You have to answer at this question:
    "When I load/find an Entity Bean, I need, at the same time,
    to load Bean related to the Entity Bean ?".
    If the answer is YES then you'll declare a CMR
    field to express the relatiosnhip.
    Moreno

Maybe you are looking for