[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] About Oracle User defined types
|
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://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
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?
___________________________________________________
<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>>
___________________________________________________
<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>