Hot questions for Using Enterprise JavaBeans in oracle


I am working with OBIEE 12c. I am trying to call a java method to save the report into the local file system with an agent. I followed the steps for 11g version at this link .I used exactly the same application names, project names, and configurations.After everything I go to OBI and click on the invoke a java method link. This is what I am getting. There is no method named "ArchiveReport". Does anyone know what might be wrong?


I finally figured out there was an issue with my mappedName for the EJB class.

I found a working example compared everything, found out the mappedName for the EJB class has to be ejb/xxxx. After changing this and regenerated the ear file. I am able to see my EJB now.


I am trying to downgrade from Jdeveloper to Jdeveloper but i faced incompatibility with java libraries.

I already followed these instructions and i replaced the jdk of Jdeveloper with the one in Jdeveloper but i still can't run my project and em.createStoredProcedureQuery is not working nor @Temporal(TemporalType.DATE)

should i update something else ?


From the 12.1.3 certification doc:

JDeveloper 12.1.3 can be configured to develop/compile against JDK 8, and introduces support for JDK 8 language features. However, the JDeveloper process must be running with JDK 7.

So you can compile it for 1.8.0 ut it would not run the app e.g. if you use ADF. You need to make it work with JDK 1.7.0


I have a Singleton EJB that initializes two entities in the beginning:

public class PetShopSingleton {

private AnimalRepository animalRepository;

private Animal cat;

private Animal dog;

public void init() {

    cat = AnimalRepository.findByType(AnimalType.CAT);

    dog = AnimalRepository.findByType(AnimalType.DOG);

The entities are initialized from a service running a named query:

public class AnimalRepository extends BaseRepository {

public Animal findByType(AnimalType type) {
    Map<String, Object> params = new HashMap<>();
    params.put("type", type);

    return findOneByNamedQuery("Animal.findByType", params,

The findOneByNamedQuery is a method in the abstract BaseRepository class:

public <T> T findOneByNamedQuery(String queryName, Map<String, Object> parameters, Class<T> clazz) {
        TypedQuery<T> typedQuery = entityManager.createNamedQuery(queryName, clazz);

    applyParameters(parameters, typedQuery);

    List<T> results = typedQuery.getResultList();
    if (!results.isEmpty()) {
        return results.get(0);

    return null;

The enumerable class used in the named query looks like this:

public enum AnimalType {

And finally the persistent entity:

@Table(name = "ANIMALS")
        name = "Animal.findByType",
        query = "select a from Animal a where a.type = :type"
public class Animal {

    private AnimalType type;

    public AnimalType getType() {
        return type;

    public void setTyp(AnimalType type) {
        this.type = type;


The one entity (cat) was an older one and was registered in the database, the newer one (dog) has been registered recently. The issue here is that the service called in the init() function to find the two entities with the named query finds only the cat. The dog is returned null although there is an entry in the database with a TYPE column equal with DOG.

Can anyone help me or give me possible reasons why this is happening?

The database is an Oracle DB.


OK I solved the issue, there was a column in the table with a file path for the animal avatar that started with C:/path/to/avatar, I changed it to /path/to/avatar and it worked. Still don't know why this happens but it's fine now :)


I have a performance issue, but, despite what it suggests in the subject, it may not be that I am using createNativeQuery. I have one fairly large query that I pass as a string to createNativeQuery. The query contains several JOINs, and is associated with 5 entities. The query takes, on average, 20 - 25 seconds to run. I have experimented, like trying the createQuery method and using the setFlushMode(FlushModeType.COMMIT), setMaxResults() and setFirstResult() methods, but made no difference.

We are using JBoss EAP 6.2 in a JTA container-managed environment, using EJB 3.0, JPA 2.1, Hibernate 4.2. The IDE I use is NetBeans 8.0.2

Yet, if I run the query directly in a SQL tool like DB Visualizer it takes milliseconds. I suspect it might have something to do with Hibernate, but am not sure. None of the Entity classes contains a collection, although there are specific relationships between the tables, as indicated in the JOIN statements in the query. I have attached some code (including the query) below.

I am hoping to retain the query as-is, but if a suggestion is made that would make it more efficient I am open to that. I appreciate that it might be difficult to answer since the query below may be difficult to analyze without knowing the database schema (this is a company project, so can only provide pseudo code in some instances). I have also not provided the Entity or Facade classes, but can provide those later if necessary. Any help would be greatly appreciated. Thank you!

public List<String> searchSingleView (String sourceSystem, String sourceClientId, String convertedClientId, String policyNum) {

   String sqlQuery = "SELECT DISTINCT " +
      "MDMCUST_ORS.C_BO_PARTY_XREF.ROWID_XREF, " +                                      "MDMCUST_ORS.C_BO_CONTRACT.LAST_ROWID_SYSTEM, " +
                                    "MDMCUST_ORS.C_BO_CONTRACT.SRC_POLICY_ID, " +
                                    "MDMCUST_ORS.C_BO_CONTRACT.ISSUE_DT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.SRC_CLIENT_ID, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.PERS_FULL_NAME_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.PERS_SRC_NAME_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.ORG_LEGAL_NAME_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.ORG_SRC_NAME_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.ORG_LEGAL_SFX_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.ORG_NAME_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.SIN_BIN_TEXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_XREF.PERS_BIRTH_DT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.LAST_UPDATE_DATE, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.COMPLETE_ADDRESS_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.TOPLINE_POSTAL_ADDR_TXT, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.CITY_NAME, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.COUNTRY_NAME, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.POSTAL_CD, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.POSTAL_ADDR_PURPOSE_CD, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.STATE_PROVINCE_NAME, " +
                                    "MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.BAD_ADDR_IND " +
                                    "FROM MDMCUST_ORS.C_BO_PARTY_XREF " +
                                    "LEFT JOIN MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF ON " + 
                                    "AND (UPPER(MDMCUST_ORS.C_BO_PARTY_XREF.SRC_CLIENT_ID) = ? " +
                                    "     OR UPPER(MDMCUST_ORS.C_BO_PARTY_XREF.CONVERTED_CLIENT_ID) = ? " +
                                    "     ) " +
                                    "AND UPPER(MDMCUST_ORS.C_BO_CONTRACT.SRC_POLICY_ID) = ? " +
                                    "AND MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.POSTAL_ADDR_PURPOSE_CD = '56|07'" +
                                    "AND MDMCUST_ORS.C_BO_PARTY_XREF.HUB_STATE_IND = '1' " +
                                    "AND MDMCUST_ORS.C_BO_CONTRACT.HUB_STATE_IND = '1' " +
                                    "AND MDMCUST_ORS.C_BO_PARTY_POSTAL_ADDR_XREF.HUB_STATE_IND = '1' " + 
                                    "AND MDMCUST_ORS.C_LU_CODES.HUB_STATE_IND = '1'" +
                                    "AND ROWNUM = 1";

try {
            querySingleView = emSingleView.createNativeQuery(sqlSingleViewQuery)
                                          .setParameter(1, sourceClientId)
                                          .setParameter(2, convertedClientId)
                                          .setParameter(3, policyNum);
            querySingleViewResult = (List<String>) querySingleView.getResultList();
        } catch (NoResultException nre) {
          // Issue a validation failure message to prevent query from continuing.
            // Display error message to user
            // Generate log entry on server
            java.util.logging.Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, nre);
        return querySingleViewResult;




will most likely prevent Oracle from using an index on SRC_POLICY_ID. MIf it is an ID I would expect it to be a number so an UPPER should not be necessary. If you really do need the UPPER than you propably should create a function based index on the column.

But without access to the database performance issues are hard to solve.

P.S.: And do you really need the DISTINCT and ROWNUMBER=1. I think you should write the query that you get only one row by using the proper conditions in the WHERE clause.


I am total newbie in Java and EE especially. I started an EE project that should provide REST API which will handle 2 entities in remote Oracle Database. I am using NetBeans because it is the only way how to accomplish anything in Enterprise Java (as I see it now).

What I've done:

  1. I created JDBC pool in Glassfish (v4.1-13). I can ping the pool successfully. Then I created JDBC Resource for the pool.
  2. I generated Entity classes for the two entities I need to handle.

<persistence version="2.1" xmlns...>
  <persistence-unit name="semestralka-ejbPU" transaction-type="JTA">
      <property name="" value="Oracle"/>


Double check the connection pool name in persistence unit and glassfish server. Also could you update your question with the entities.


I have a callableStatment, upon execution I get the below error

    catch (Throwable t) {
                throw new Exception(t);

            finally {

javax.ejb.EJBTransactionRolledbackException: ORA-30926: unable to get a stable set of rows in the source tables

After some time I get Database Error of "Too man open cursors"

I know that the procedure is throwing the error due to duplication, I want to know why the Cursors aren't closed as it seems finally block is not doing what I need and what is the proper way to close them


I think you are executing a merge query and there is more than 1 row id returned. And this is the reason for that exception. Also when the first duplicate row is returned, there itself the exception is thrown. And before the query is even executed you are trying to close it. That should be the reason for the cursor not closing properly. Try adding a distinct keyword in your query to avoid duplicates. Eg: MERGE INTO table_1 a USING (SELECT distinct ta.ROWID row_id FROM table_1 a ,table_2 b ,table_3 c WHERE ) src ON ( a.ROWID = src.row_id ) WHEN MATCHED THEN ;As there is a rollback involved, it comes under System Exception. And Application Exceptions are not rolled back.