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

Similar Messages

  • Business components mapped to EJB 2.0 local entity beans

    Hi ,
    I read about the new feature in JDev 903 that is "Creating business components mapped to EJB 2.0 local entity beans". but I am not able to find any documentation on it.can anyone provide me any link or help on this topic.
    Thanx,
    Prasoon

    Prasoon -
    For JDeveloper 10g, version 9.0.5.1, there is information on this topic located in the help:
    Building J2EE Applications >
    Working with the Business Tier >
    Developing Enterprise JavaBean Applications >
    Using Business Component Entity Facades
    Hope this helps,
    Lynn
    Java Tools Team

  • Data Warehouse report query using Entity Beans

    I have used the EJB technology on one project, so I am not all that familiar with
    best practices.
    In my new project, I have to produce reports using a query that goes against a
    dimensional database. I am wondering what options I have to run the query and
    extract the results given that the application will run on WebLogic.
    1) Straight JDBC
    2) BMP
    3) CMP (could be a problem because the quety is a join query, but I am not sure
    if WebLogic requires that the query is against a table rather than a view)
    The query is read-only. I am more interested in ease of coding and code management
    rather than application performance at this point because I think the query will
    spend a relatively large time executing on the Oracle database.
    I would like to hear the best practices to be employed in this case. Thanks very
    much!
    Ravi.

    Don't use entity beans for this. Straight JDBC is not perfect either, but it
    is preferable to entity beans for this type of work.
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Ravi Navanee" <[email protected]> wrote in message
    news:3c92693d$[email protected]..
    >
    I have used the EJB technology on one project, so I am not all thatfamiliar with
    best practices.
    In my new project, I have to produce reports using a query that goesagainst a
    dimensional database. I am wondering what options I have to run the queryand
    extract the results given that the application will run on WebLogic.
    1) Straight JDBC
    2) BMP
    3) CMP (could be a problem because the quety is a join query, but I am notsure
    if WebLogic requires that the query is against a table rather than a view)
    The query is read-only. I am more interested in ease of coding and codemanagement
    rather than application performance at this point because I think thequery will
    spend a relatively large time executing on the Oracle database.
    I would like to hear the best practices to be employed in this case.Thanks very
    much!
    Ravi.

  • Named query in Entity Bean - Problem with embedded class

    Hello Forum,
    I'm trying to set up a named query in my Entity Bean and I'm unable to get
    it up and running for an embedded class object.
    The class hierarchy is as follows:
             @MappedSuperclass
             AbstractSapResultData (contains dayOfAggregation field)
                     ^
                     |
            @MappedSuperclass
            AbstractSapUserData (contains the timeSlice field)
                     ^
                     |
              @Entity
              SapUserDataThe named query is as follows:
    @NamedQuery(name = SapUserDataContext.NAMED_QUERY_NAME_COUNT_QUERY,
                                query = "SELECT COUNT(obj) FROM SapUserData AS obj WHERE "
                                         + "obj.sapCustomerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_CUSTOMER_ID
                                         + " AND "
                                         + "obj.sapSystemId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SYSTEM_ID
                                         + " AND "
                                         + "obj.sapServerId"
                                         + "= :"
                                         + SapResultDataContext.COLUMN_NAME_SAP_SERVER_ID
                                         + " AND "
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATION
                                         + " AND "
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime")The query deploys and runs except that part:
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONI don't see any difference to the part of the query accessing the timeSlice
    field which is also an embedded class object - I access it in exactly the same way:
                                         + "obj.timeSlice.startTime"
                                         + "= :"
                                         + "timeSliceStartTime"
                                         + " AND "
                                         + "obj.timeSlice.endTime"
                                         + "= :"
                                         + "timeSliceEndTime"The problem is that the complete query runs on JBoss application server
    but on the SAP NetWeaver application server it only rund without the
                                         + "obj.dayOfAggregation.calendar"
                                         + "= :"
                                         + DayContext.COLUMN_NAME_DAY_OF_AGGREGATIONpart - If I enable that part on SAP NetWeaver the server complains:
    [EXCEPTION]
    {0}#1#java.lang.IllegalArgumentException: line 1: Comparison '=' not defined for dependent objects
    SELECT COUNT(obj) FROM SapUserData AS obj WHERE obj.sapCustomerId= :sap_customer_id AND obj.sapSystemId= :sap_system_id AND obj.sapServerId= :sap_server_id AND obj.dayOfAggregation.calendar= :day_of_aggregation AND obj.timeSlice.startTime= :timeSliceStartTime AND obj.timeSlice.endTime= :timeSliceEndTime
                                                                                                                                                                                                 ^I know that this isn't an application server specific forum but the SAP NetWeaver server is the most strict EJB 3.0 and JPA 1.0 implementation I've seen so far so I think I'm doing something wrong there.
    Someone in the SAp forum mentioned:
    The problem here is that you compare an input-parameter with an embeddable field of your entity.
    Regarding to the JPQL-grammer (spec 4.14) you are not allowed to compare
    with the non-terminal embeddable field but with the terminal fields of your
    embeddable. Stating that your embedded class might have the fields
    startTime and endTime your JPQL query might look like this:
    Query q = em.createQuery("SELECT count(obj.databaseId) FROM SapUserData obj WHERE obj.timeSlice.startTime = :startTime AND obj.timeSlice.endTime = :endTime");
    q.setParameter("startTime", foo.getStartTime());
    q.setParameter("endTime", foo.getEndTime());
    q.getResultList();
    This limitation in the JPQL grammar is rather uncomfortable.
    An automatic mapping of the parameter's fields to the terminal fields of your
    embedded field would be more convenient. The same can be said for lists
    as parameter-values which is possible in HQL, too. I think we have to wait
    patiently for JPA 2.0 and hope for improvements there. :-)
    With that help I was able to get it up and running for the timeSlice field but
    I don't see the difference to the dayOfAggregation field which is also just
    another embedded class using an object of a class annotated with
    @Embeddable.
    The get method of the dayOfAggregation field is as follows:
         * Get method for the member "<code>dayOfAggregation</code>".
         * @return Returns the dayOfAggregation.
        @Embedded
        @AttributeOverrides({@AttributeOverride(name = "calendar", /* Not possible to use interface constant here - field name must be used for reference */
                                                column = @Column(name = DayContext.COLUMN_NAME_DAY_OF_AGGREGATION,
                                                                 nullable = false)),
                             @AttributeOverride(name = "weekday",
                                                column = @Column(name = DayContext.COLUMN_NAME_WEEKDAY,
                                                                 nullable = false)),
        public Day getDayOfAggregation() {
            return this.dayOfAggregation;
        }The link to my question in the SAP forum for reference:
    https://www.sdn.sap.com/irj/sdn/thread?messageID=3651350
    Any help or ideas would be greatly appreciated.
    Thanks in advance.
    Henning Malzahn

    Hello Forum,
    got a response in the SAP forum - Issue is a bug in the SAP NetWeaver
    app. server.
    Henning Malzahn

  • EJB 3.0: CMP Entity bean from view

    Hi,
    I have created an entity bean from a database view.
    I don't have a good filed to use as id in my view. So I want to generate the id in my entity bean.
    How can I do this ?
    Thanks

    Hi,
    I didn't get your question.
    CMP is something, which can be done by hand.
    So maybe it is better, to do it manually.
    Bea has some workaround, I am sure.
    Maybe it is something with deployment descriptors, which
    have to be configured to the underlying database.
    Sorry for my stupid first answer.
    Volker.

  • How can I control the EJB's Transaction with entity bean

    If I use entity bean, the Transaction is managed by container.and I want to create JDBC Connection by myselft ,not the Datasource,how is the transaction is controlled by the container,if transaction is not controlled ,how can I control it??

    Hi,
    If you want to control the transaction your self then you need to use javax.transaction.UserTransaction interface and methods defined by it.
    Hope this helps
    Vishal

  • EJB 2.0 cmp entity beans problem with 8.17

    I have a little application as client JBuilder,Weblogic 7.0 on the middleware
    and 8.17 personnal at the backend,with Cloudscape java database,it worked fine.
    I have two tables in it,with a one-to-many relationship,the ClientID from the Clients Table is foreign key in the other.
    But now with 8.17 I have a RollbackException(cannot create Factures instance with the foreign key field null)so I cannot create any instance at the many side from the relation because the ClientID which is with EJB2.0 not a cmp field,is put automatically by the container in the table,
    but this process seems not to work with 8.17,
    what can I do?
    Have someone a solution?

    Hi,
    I didn't get your question.
    CMP is something, which can be done by hand.
    So maybe it is better, to do it manually.
    Bea has some workaround, I am sure.
    Maybe it is something with deployment descriptors, which
    have to be configured to the underlying database.
    Sorry for my stupid first answer.
    Volker.

  • Entity bean questions

    what is the sequence of events that takes place after, findAll method on EJB Home of an entity bean is called. In particular I want to know when EJB Objects are created? I am not able to understand this from Entity Bean lifecycle.

    The underlying query will return zero or more primary keys to the container. The container then converts each primary key into its corresponding EJBObject or EJBLocalObject, depending on the interface through which the findAll call was made. In some cases, the EJBObject/EJBLocalObject already exists within the container. In other cases the container needs to create a new EJBObject/EJBLocalObject for the primary key. The resulting set of EJBObjects is then returned to the caller.

  • Which WebLogic XDoclet Properties to set for Entity Beans

    I have no documentation about howto set the WebLogic XDoclet properties (in a EJB Project).
    The Entity Beans used by me, are CMP's accessing an Oracle Data Source (allready setup by me in the WebLogic console).
    If someone knows documentation about this, or some example of a CMP (with @weblogic tags) that is backed by an Oracle table, I will appreciate that very much

    Hi ,
    Go through the following link,In that you will find the weblogic tags and will get some needfull information on this issue.
    http://dev2dev.bea.com/pub/a/2002/03/243.html
    Regards
    Anilkumar kari

  • Calling Local Entity Beans from another Application

    Hi,
    I packaged all my Local entity Beans in 1 single Application (APP1.EAR).
    I then I have another Application (APP2.EAR) which is made of Session Beans which require access to the APP1 application.
    I'm using this code to achieve this:
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "admin");
    env.put(Context.SECURITY_CREDENTIALS, "manager");
    env.put(Context.PROVIDER_URL, "ormi://<host>/APP1");
    context = new InitialContext(env);
    ... (BeanLocalHome)context.lookup("java:comp/env/ejb/BeanLocal");
    I get the Following Exception:
    javax.naming.NameNotFoundException: java:comp/env/ejb/BeanLocal not found
    1) is there any problem with this code?
    2) can local interfaces be accessed by another Application (or can they be accessed only by the same application) ?
    Regards.
    giuseppe.

    Hi ,
    thank you for your answer.
    I'm still in trouble:
    these are the steps:
    App1.jar entity beans.
    App2.jar Session bean.
    I embedded the App1.jar into the App2.ear
    dir :
    App1.jar
    App2.jar
    application.xml (added the App1.jar)
    then I added this in the ejb-jar.xml deployment descriptor for App2.jar
    <ejb-link>../App1.jar#BeanName</ejb-link>
    for each entity bean.
    But I still get :
    javax.naming.NameNotFoundException: java:comp/env/ejb/BeanNameLocal not found
    java.lang.Object com.evermind.server.ApplicationContext.lookup(java.lang.String, boolean)
    ApplicationContext.java:110
    java.lang.Object com.evermind.server.ApplicationContext.lookup(java.lang.String)
    ApplicationContext.java:66
    java.lang.Object javax.naming.InitialContext.lookup(java.lang.String)
    What am I missing ??
    Thanks.
    giuseppe.

  • Query about reentrant in ejb-jar.xml file(in case of entity Bean)

    Hi all friends,
    I am new to EJB I couldn't understand in ejb-jar.xml file in case Entity Bean[<reentrant>False</reentrant>
    &<reentrant>true</reentrant>]what is the function of this tag and what is the effect of value true and false of this tag.Can any one please explain it.
    Regards
    Bikash

    Hi,
    Re-entrant tag is used in the ejb-jar.xml to notify the container if you would want your bean to call itself through another bean.
    Most of the time you would want it to be set to FALSE because you would have to consider the multi-threading issues if you set it TRUE.
    Regards
    Meka Toka

  • Change one entity bean query, errors pop up in another... why?

    In my application I have the following entity bean:
    @Entity
    @Table(name = "ventureprofile")
    @SecondaryTable(name = "venture")
    @NamedQueries( {       
            @NamedQuery(name = "Ventureprofile.findByVentureprofileid", query = "SELECT v FROM Ventureprofile v WHERE v.ventureprofileid = :ventureprofileid"),
            @NamedQuery(name = "Ventureprofile.findByVentureid", query = "SELECT v FROM Ventureprofile v WHERE v.ventureid = :ventureid"),
            @NamedQuery(name = "Ventureprofile.findByLogoimagelocation", query = "SELECT v FROM Ventureprofile v WHERE v.logoimagelocation = :logoimagelocation"),
            @NamedQuery(name = "Ventureprofile.findByVisible", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename")
            //@NamedQuery(name = "Ventureprofile.findByVisibleRange", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename OFFSET 1 LIMIT 2")
    public class Ventureprofile implements Serializable {
        @GeneratedValue(strategy=GenerationType.AUTO, generator="Ventureprofile.ventureprofileid.seq")
        @SequenceGenerator(name="Ventureprofile.ventureprofileid.seq", sequenceName="ventureprofile_ventureprofileid_seq", allocationSize=1) 
        @Column(name = "ventureprofileid", nullable = false)
        private BigInteger ventureprofileid;
        @Id
        @JoinColumn(name = "ventureid", referencedColumnName = "ventureid")
        private long ventureid;  
        @Lob
        @Column(name = "venturesummary")
        private String venturesummary;
        @Column(name = "logoimagelocation")
        private String logoimagelocation;
        @Column(name = "visible", nullable = false)
        private char visible;
        @Column(table = "venture", name = "venturename", insertable=false)
        private String venturename;
    ...and another entity bean:
    @Entity
    @Table(name = "venturelink")
    @NamedQueries( {
            @NamedQuery(name = "Venturelink.findByVenturelinkid", query = "SELECT v FROM Venturelink v WHERE v.venturelinkid = :venturelinkid"),
            @NamedQuery(name = "Venturelink.findByVentureprofileid", query = "SELECT v FROM Venturelink v WHERE v.ventureprofileid = :ventureprofileid"),
            @NamedQuery(name = "Venturelink.findByLinkurl", query = "SELECT v FROM Venturelink v WHERE v.linkurl = :linkurl"),
            @NamedQuery(name = "Venturelink.findByLinkname", query = "SELECT v FROM Venturelink v WHERE v.linkname = :linkname")
    public class Venturelink implements Serializable {
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO, generator="Venturelink.venturelinkid.seq")
        @SequenceGenerator(name="Venturelink.venturelinkid.seq", sequenceName="venturelink_venturelinkid_seq", allocationSize=1)  
        @Column(name = "venturelinkid", nullable = false)
        private BigInteger venturelinkid;
        @Column(name = "ventureprofileid", nullable = false)
        private long ventureprofileid;
        @Column(name = "linkurl", nullable = false)
        private String linkurl;
        @Column(name = "linkname", nullable = false)
        private String linkname;
    ...    If I uncomment the last NamedQuery ~
    @NamedQuery(name = "Ventureprofile.findByVisibleRange", query = "SELECT v FROM Ventureprofile v WHERE v.visible = :visible ORDER BY v.venturename OFFSET 1 LIMIT 2")I experience the following runtime error:
    javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
            java.rmi.RemoteException: null; nested exception is:
            java.lang.IllegalArgumentException: NamedQuery of name: Venturelink.findByVentureprofileid not found.Container: Glassfish
    Database: Postgres
    OS: WinXP sp2
    Persistence provider: Toplink
    Note that I am not altering 'Venturelink', I am only altering 'Ventureprofile', however errors are manifesting themselves in 'Venturelink'.
    I have heard a rumor that 'OFFSET' and 'LIMIT' are not supported by the majority of persistence providers, but that would be a ridiculous situation... unless the majority of persistence providers lazy-load results when they are pulled from a result set. Is that the case?
    Regardless, this is making me guess what is going on behind the scenes. So, at some point during runtime, is all of my EJB query code getting munged together? And then whatever interprets them into SQL is giving up as soon as it finds a query it doesn't like? That's what this smells like, at least...
    Typically, I find weird errors like this crop up when I'm doing something stupid that a system wasn't designed to handle. So I'd really appreciate it if someone would set me straight.

    Solution, via Doug Clarke at the TopLink forums:
    2. JPA's query language does not support OFFSET and LIMIT. Instead JPA offers setFirstResult(int) and setMaxResult(int) on the Query object. In TopLink this generally translates to JDBC calls of similar names.
    (Thanks Doug!)
    so yeah... unless somebody knows otherwise and I'm wrong (often the case), looks like things choke across multiple entity beans as soon as one malformed query is found. Not good.

  • CMP Entity Bean with ejb-ql finder methods and INFORMIX database

    Hi,
    I have some CMP Entity Beans with finder methods defined in ejb-ql. In my ejb-jar, within <entity> definitions I have something like:
        <entity>
          <abstract-schema-name>BeanName</abstract-schema-name>
          <cmp-field><field-name>fieldOne</field-name></cmp-field>
          <cmp-field><field-name>fieldTwo</field-name></cmp-field>
          <query>
            <query-method>
              <method-name>findAll</method-name>
              <method-params></method-params>
            </query-method>
            <ejb-ql>SELECT OBJECT(o) FROM BeanName o</ejb-ql>
          </query>
        <entity>
    And in persistent.xml:
    <db-properties>
         <data-source-name>datasource_name</data-source-name>
    </db-properties>
    <entity-bean>
         <ejb-name>BeanName</ejb-name>
         <table-name>table_name</table-name>
         <field-map key-type="NoKey">
         <field-name>fieldOne</field-name>
         <column><column-name>column_one</column-name></column>
          </field-map>
         <field-map key-type="NoKey">
         <field-name>fieldTwo</field-name>
         <column><column-name>column_two</column-name></column>
          </field-map>
          <finder-descriptor>
              <method-name>findAll</method-name>
              <method-params/>
         </finder-descriptor>
    Once deployed, on server side, I can found a java source file (with corresponding compiled class file) in path:
    j2ee/cluster/server0/apps/companyName/MyEARApp/EJBContainer/temp/temp38837373733/route/to/package/
    with names:
    BeanName0_0pm.java
    BeanName0_0PM.class
    and the generated java file contains this code:
      public java.util.Enumeration ejbFindAll() throws javax.ejb.FinderException, javax.ejb.EJBException  {
        TransactionContext tc = pm.getTransactionContext();
        Connection conn = null;
        PreparedStatement pSt = null;
        ResultSet ejb_rs = null;
        int status = javax.transaction.xa.XAResource.TMSUCCESS;
        try {
          conn = pm.getConnectionForFindMethod();
          pSt = conn.prepareStatement("SELECT \"O\".\"COLUMN_ONE\",\"O\".\"COLUMN_TWO\", FROM \"TABLE_NAME\" \"O\"");
          ejb_rs = pSt.executeQuery();
    I'm trying to call this method but it throws a SQLException when preparing the statement.
    It seems that Informix does not like this SQL syntax because of upper case names, doble quotes on table alias, or something else.
    When editing persistent.xml in netweaver, I can define the element <datasource-vendor> as ORACLE, SAPDB, MS_SQL_SERVER, DB2_UDB_AS400 or DB2_UDB_OS390 but INFORMIX is not an accepted value.
    Is there any way to define how this SQL query is build?
    Thanks in advance.

    The return type of the finder method defined in the remote home interface is either the entity bean's remote interface or a collection of objects implementing the entity bean's remote interface. The return type of the finder method defined in the local home interface is either the entity bean's local interface or a collection of objects implementing the entity bean's local interface

  • Problem with ejb 3.0 entity beans with manyToMany relationship

    Hello everyone!
    I am using struts 1.2.9 and java ee 5 sdk update 2 for my enterprise application. Besides others i have these entity beans Targetgroup.java and City.java, (i would upload file but i do not know how:)
    with manytomany relationship with join table.
    when user updates Targetgroup, by clicking on web page with checkboxes and textfields, struts dispatch action calls following method stateless bean:
    public void update(String firmId, String targetgroupId, String newGender, String newMinYearsOld, String newMaxYearsOld, String[] newCities) {
    TargetgroupPK pkForUpdate = new TargetgroupPK(targetgroupId, firmId);
    Targetgroup targetgroupForUpdate = find(pkForUpdate);
    targetgroupForUpdate.setGender(newGender);
    targetgroupForUpdate.setMinyearold(Integer.parseIn t(newMinYearsOld));
    targetgroupForUpdate.setMaxyearold(Integer.parseIn t(newMaxYearsOld));
    //pronalazenje gradva za koje je vezana ciljna grupa
    Collection<City> newCitiesCollection = new ArrayList<City>();
    for(int i = 0; i < newCities.length; i++){
    String tmp_city_name = newCities;
    City city_obj = cityFacade.find(tmp_city_name);
    newCitiesCollection.add(city_obj);
    targetgroupForUpdate.setCityidCollection(newCities Collection);
    parameter newCities represents names of cities which user checked on his update page. When the page is showen to him some cities are allready check because they were connected with Targetgruoup when it was created (targetgroup).
    this code throws following exception:
    [#|2007-07-26T12:13:36.993+0200|SEVERE|sun-appserver-pe9.0|javax.enterprise.system.container.web|_Threa dID=16;_ThreadName=httpWorkerThread-8080-0;_RequestID=f79d9c50-86b0-4b6c-96ab-97956dfb39c1;|StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    javax.transaction.RollbackException: Transaction marked for rollback.
    at
    .com.sun.enterprise.web.connector.grizzly.WorkerTh read.run(WorkerThread.java:75)
    javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
    at com.sun.ejb.containers.BaseContainer.completeNewTx (BaseContainer.java:3659)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:3431)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1247)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:1 92)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:71)
    at $Proxy149.update(Unknown Source)
    at audiotel.sms.actions.backoffice.TargetgroupDispatc hAction.updateOrDelete(TargetgroupDispatchAction.j ava:132)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:270)
    at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:187)
    at org.apache.struts.action.RequestProcessor.processA ctionPerform(RequestProcessor.java:431)
    at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:236)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1196)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:432)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:727)
    com.sun.enterprise.web.connector.grizzly.WorkerThr ead.run(WorkerThread.java:75)
    |#]
    exceprion is throwen ONLY when in parameter newCities are city names allready connected to Targetgroup. when NewCities contains names of
    City objects which are not connected to Targetgroup it works fine, but it's of no use for me, because user must be able to add or remove certian cities from relaionship with Targetgroup. I think it's because there are rows in join table that contain primary keys of city and targetgroup which are connected so perisistence manager cann't write them again.
    i thought it was going to figure it out by itself, and only update those rows.
    Does anyone know what is the problem and solution?
    Thanks! (forgive my spelling errors :)

    solved the problem!
    I moved code from sesion bean to struts action as follows:
    CityFacadeLocal cityFacade = lookupCityFacade();
    //prikupljanje novih podataka o ciljnoj grupi
    String newGender = ctf.getGender();
    String newMaxYears = ctf.getMaxyears();
    String newMinYears = ctf.getMinyears();
    String[] newSelectedCities = ctf.getSelectedCities();
    //niz imena gradova se prevodi u kolekcju objekata City
    Collection<City> newCitiesObjCollection = new Vector<City>();
    for(int i = 0; i < newSelectedCities.length; i++){
    String tmpCityName = newSelectedCities;
    City tmpCityObj = cityFacade.find(tmpCityName);
    newCitiesObjCollection.add(tmpCityObj);
    //setovanje novih podataka
    targetgroupForUD.setGender(newGender);
    targetgroupForUD.setMinyearold(Integer.parseInt(newMinYears));
    targetgroupForUD.setMaxyearold(Integer.parseInt(newMaxYears));
    targetgroupForUD.setCityidCollection(newCitiesObjCollection);
    //pozivanje update metdoe u session beany
    targetgroupFacade.edit(targetgroupForUD);
    //korisnik se vraca na stranu sa svim postojecim ciljnim grupama
    forward = mapping.findForward("backend.targetgroups");
    and now it works fine. I guess probelm was same transaction scope for Targetgroup and City entities. Now when they are separated it works.
    Thanks!

  • Problems accessing tables in oracle database with ejb entity bean

    I have created a simple server application that uses an entity bean (version 2.0) for an existing table in oracle database, and a session bean that is used as an outside interface for performing operations on that table.
    after deploying the server and client application the client attempts to perform an operation with the session bean remote interface it obtained.
    The session bean uses a locale interface to communicate with the entity bean, but when it tries to use its methods (create, findByXXX) it always get the following Exception: java.sql.SQLException: ORA-00942: table or view does not exist.
    the table of course exists, and the username password I'm using has all the permissions needed for this table.
    note - I'm using the Forte enterprise edition 4.0 as developer tool.
    I'll be glad to get some help.
    Here is the full stack trace of the exception:
    javax.ejb.TransactionRolledbackLocalException: Exception thrown from bean; nested exception is: javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    javax.ejb.EJBException: nested exception is: java.sql.SQLException: ORA-00942: table or view does not exist
    java.sql.SQLException: ORA-00942: table or view does not exist
    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.parseExecuteDescribe(TTC7Protocol.java:643)
    at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:1674)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1870)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:363)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:314)
    at com.sun.ejb.persistence.SQLEngine.ejb20Finder(SQLEngine.java:226)
    at com.sun.ejb.persistence.PartitionImpl.ejbFinder(PartitionImpl.java:736)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM.ejbFindByEmail(UserInfoEJB_PM.java:393)
    at com.cti2.telco.core.ejb.entity.userInfo.UserInfoEJB_PM_LocalHomeImpl.findByEmail(UserInfoEJB_PM_LocalHomeImpl.java:64)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:77)
    at com.cti2.telco.core.ejb.UserManagerEJB.authenticate(UserManagerEJB.java:68)
    at com.cti2.telco.core.ejb.UserManagerEJB_EJBLocalObjectImpl.authenticate(UserManagerEJB_EJB
    LocalObjectImpl.java:63)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB.userLogin(TelcoFacadeEJB.java:80)
    at com.cti2.telco.core.ejb.dispatch.TelcoFacadeEJB_EJBObjectImpl.userLogin(TelcoFacadeEJB_EJBObjectImpl.java:24)
    at com.cti2.telco.core.ejb.dispatch._TelcoFacadeEJB_EJBObjectImpl_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)
    ...

    Well it seems like the problems has a simple explanation. The Forte assigns a default table name (<entityName>EJBTable) when creating an entity bean from an existsing table in DB (which is not the same as the one it was created from !!!). Also, for reason unknown, when you deploy these entity beans, it doesn't even create the new table under its new name (even if instructed to).
    So using the Forte we managed to use successfuly only entity beans that were created "from scretch" (when deployed their tables are created).
    Does anyone know how to change the default name the Forte uses, and make it work properly with entity beans created from an existsing table (without going over the xml's) ?

Maybe you are looking for

  • Financial reports 9.2 - Network Error

    Hi All, We've one financial report which behaves very strange sometime. Sometime I can open the report, but there are times when I get the below error message: 5200: Error executing query: colhyp77.corp.com/WSO/Plan//Error(1042013) Network error [100

  • Programatically, Can I determine the size in bytes of each page of a pdf  using C++ and Acrobat X?

    Hi, I need to create an MFC application to open a pdf and get the size of each page in Bytes. Is it possible??? I am really appreciate to your help. Thanks

  • Motion 3 "broken" after crash

    Motion 3 crashed in the middle of a project 2 days ago. Since then, every time I open the program, I can't get the File Browser window to show up, and I can't "Add Behavior" or "Add Filter" (both buttons appear active, but when I hit them, nothing ha

  • Emailing Adhoc Query Output

    Dear Friends, I have a requirement in which HR managers needs to be delivered some reports in his mail early morning. The query to extract the required data is already developed and this can be scheduled early morning to retrive the data. Is there an

  • Is there a program that automatically creates smart playlists

    Hi, I recently had my Itunes music library file damaged/corrupted, hence i lost all my playlists. Before I spend 4/5 hours recreating my playlists I wondered if anyone knew if there was a program in cyberspace somewhere that would automatically creat