Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] About Oracle User defined types

Hi folks.

Using descriptor.useNoIdentityMap() fixed the previous problem. But, this is the new error message:

java.lang.NullPointerException
at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getMethodParameterTypes(PrivilegedAccessHelper.java:323)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getSetMethodParameterType(MethodAttributeAccessor.java:168)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.getSetMethodParameterType(MethodAttributeAccessor.java:156)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:282)
at org.eclipse.persistence.internal.descriptors.MethodAttributeAccessor.setAttributeValueInObject(MethodAttributeAccessor.java:226)

I read about the security permissions. I setted 

permission java.lang.reflect.ReflectPermission "suppressAccessChecks";  
    permission java.lang.RuntimePermission "accessDeclaredMembers";
    permission java.lang.RuntimePermission "getClassLoader";
    permission java.lang.RuntimePermission "getMethodParameterTypes";

in my JVM, but anything changed.

Help.



2012/1/20 Luis Dominguez <ldominguez.integra@xxxxxxxxx>
I have this error

at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.getIdentityMap(IdentityMapManager.java:923)
at org.eclipse.persistence.internal.identitymaps.IdentityMapManager.acquireLock(IdentityMapManager.java:144)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock(IdentityMapAccessor.java:92)
at org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock(IdentityMapAccessor.java:83)
at org.eclipse.persistence.internal.sessions.AbstractSession.retrieveCacheKey(AbstractSession.java:4567)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:668)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:612)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:565)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:497)
at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:456)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:723)
at org.eclipse.persistence.queries.ReadAllQuery.registerResultInUnitOfWork(ReadAllQuery.java:742)
at org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:423)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1080)
at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:808)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1040)
at org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:383)
at org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1126)
at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2842)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1521)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1503)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1477)
at org.luisd.App.main(App.java:91)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

And this is what i did:

ClassDescriptor descriptor = new ClassDescriptor();
        descriptor.useNoIdentityMap();

        ObjectArrayMapping pricesMapping = new ObjectArrayMapping();
         pricesMapping  .setReferenceClass(PType.class);
         pricesMapping  .setAttributeName("pricesList");
         pricesMapping  .setFieldName("PRICES_LIST");
         pricesMapping  .setStructureName("CT_PRICE");
         pricesMapping  .readOnly();
         pricesMapping  .setGetMethodName("getPricesList");
         pricesMapping  .setSetMethodName("setPricesList");

        descriptor.addMapping( pricesMapping   );

StoredProcedureCall call = new StoredProcedureCall();
        call.setProcedureName("PKG.GET_DEVICES");
        call.useNamedCursorOutputAsResultSet("v_list");
        call.addNamedArgument("v_id");
        call.addNamedArgument("v_class");
        call.addNamedArgument("v_date");

ReadAllQuery query = new ReadAllQuery();
        query.addArgument(" v_id ");
        query.addArgument(" v_class ");
        query.addArgument(" v_date ");
        query.setDescriptor(descriptor);
        query.setCall(call);

List<Object> queryArgs = new ArrayList<Object>();
        queryArgs.add(new Long(12));
        queryArgs.add("p1");
        queryArgs.add(new Timestamp(System.currentTimeMillis()));

Session activeSession = ((JpaEntityManager) main.em.getDelegate()).getActiveSession();
List< PType > queryResultList = (List) activeSession.executeQuery(query, queryArgs);

Help.

2012/1/20 Tom Ware <tom.ware@xxxxxxxxxx>
We have direct support for Arrays that has been around for quite a while.  (and JPA mapping support starting in EclipseLink 2.3)

Documentation Link:

http://wiki.eclipse.org/Configuring_an_Object-Relational_Data_Type_Array_Mapping_(ELUG)


JPA Mapping info:

http://www.eclipse.org/eclipselink/api/2.3/index.html

-Tom


On 20/01/2012 3:28 PM, Luis Dominguez wrote:
Like this:

Map types = conn.getTypeMap();
types.put("C_PriceType", PriceType.class);
conn.setTypeMap(types);

java.sql.Array priceList  = rs.getArray("PRICE_LIST");



2012/1/20 Tom Ware <tom.ware@xxxxxxxxxx <mailto:tom.ware@xxxxxxxxxx>>


   How would you access the fields of the object if you were using JDBC?

   -Tom


   On 20/01/2012 9:58 AM, Luis Dominguez wrote:




       The Stored Procedures is in an oracle database. The procedure returns a
       sys_refcursor, where the cursor has the following fields:

       ID: it's a number field type.
       Prices List: It's a list of Price type. An oracle user defined type with te
       following structure:
             * Id of price item: Number field
             * priceAmount: amount. It's a NUMBER(12, 5) field.

       If i used DataReadQuery with a StoredProcedureCall, the result list when the
       query is executed has a list of DatabaseRecord, where the records has an
       object
       array for the prices list.

       I need to obtain the prices values, but using DataReadQuery the prices
       list is
       returned as an Object array, with Object type elements, and no
       possibilities to
       cast to the desired object.

       Help.


           2012/1/20 Tom Ware <tom.ware@xxxxxxxxxx <mailto:tom.ware@xxxxxxxxxx>
       <mailto:tom.ware@xxxxxxxxxx <mailto:tom.ware@xxxxxxxxxx>>>



               Can you explain a little more about what this custom type is?  We
               provide a number of ways you can deal with special types and
       your choice
               will depend on how it is derived.

               At the simplest level, you can specify a Converter on the object
       that
               maps to the special type.  That will allow you do do some
       operations.

       http://wiki.eclipse.org/Using_____EclipseLink_JPA_Extensions_%____28ELUG%29#Using_EclipseLink_____JPA_Converters
       <http://wiki.eclipse.org/Using___EclipseLink_JPA_Extensions_%__28ELUG%29#Using_EclipseLink___JPA_Converters>

       <http://wiki.eclipse.org/__Using_EclipseLink_JPA___Extensions_%28ELUG%29#Using___EclipseLink_JPA_Converters

       <http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_%28ELUG%29#Using_EclipseLink_JPA_Converters>>

               Alternately, we have an event mechanism that will allow you to
       access
               the data at various points in the query.

       http://www.eclipse.org/____eclipselink/api/2.3/index.html
       <http://www.eclipse.org/__eclipselink/api/2.3/index.html>

       <http://www.eclipse.org/__eclipselink/api/2.3/index.html
       <http://www.eclipse.org/eclipselink/api/2.3/index.html>__>


               If the data structure is, in fact, a Struct, you may be able to
       make use
               of our StructConverter to operate on it as it enters and leaves the
               database.

       http://wiki.eclipse.org/Using_____EclipseLink_JPA_Extensions_(____ELUG)#How_to_Use_the_.____40StructConverter_Annotation
       <http://wiki.eclipse.org/Using___EclipseLink_JPA_Extensions_(__ELUG)#How_to_Use_the_.__40StructConverter_Annotation>

       <http://wiki.eclipse.org/__Using_EclipseLink_JPA___Extensions_(ELUG)#How_to_Use___the_.40StructConverter___Annotation

       <http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#How_to_Use_the_.40StructConverter_Annotation>>

               -Tom



               On 19/01/2012 4:08 PM, Luis Dominguez wrote:

                   Hi everybody.

                   I'm using eclipselink with JPA. Actually, i'm using
       eclipselink for
                   a stored
                   procedure call. The results of the stored procedure have a
       "column",
                   with a
                   custom type object value. The sentence

                   List<DatabaseRecord> queryResultList = (List)
       ((JpaEntityManager)

         main.em.getDelegate()).____getActiveSession().____executeQuery(query,


                   queryArgs);

                   recovers a list of DatabaseRecord, with a field as
                   [Ljava.lang.Object;@10010ec
                   object. When i'm trying to iterate this array, only have a
                   [Ljava.lang.Object;,
                   with no possibilities of see the data.

                   How i can do that?





                   ___________________________________________________

                   eclipselink-users mailing list
       eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@eclipse.org>
       <mailto:eclipselink-users@__eclipse.org
       <mailto:eclipselink-users@eclipse.org>>
       https://dev.eclipse.org/____mailman/listinfo/eclipselink-____users
       <https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users>
       <https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
       <https://dev.eclipse.org/mailman/listinfo/eclipselink-users>>

               ___________________________________________________

               eclipselink-users mailing list
       eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@eclipse.org>
       <mailto:eclipselink-users@__eclipse.org
       <mailto:eclipselink-users@eclipse.org>>
       https://dev.eclipse.org/____mailman/listinfo/eclipselink-____users
       <https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users>


       <https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
       <https://dev.eclipse.org/mailman/listinfo/eclipselink-users>>





       _________________________________________________
       eclipselink-users mailing list
       eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@eclipse.org>
       https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
       <https://dev.eclipse.org/mailman/listinfo/eclipselink-users>

   _________________________________________________
   eclipselink-users mailing list
   eclipselink-users@xxxxxxxxxxx <mailto:eclipselink-users@eclipse.org>
   https://dev.eclipse.org/__mailman/listinfo/eclipselink-__users
   <https://dev.eclipse.org/mailman/listinfo/eclipselink-users>




_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top