Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Eclipselink - error mapping oracle object when calling stored procedure(Eclipselink - error mapping oracle object when calling stored procedure)
Eclipselink - error mapping oracle object when calling stored procedure [message #1744839] Fri, 30 September 2016 16:38
graeme kitchen is currently offline graeme kitchenFriend
Messages: 5
Registered: September 2016
Junior Member

I am running the following eclipselink piece of code. But I am missing the step of my mapping my objecty called YOUR_OBJECT to the plsql side of things as I recieve the below error.

Does anybody have any good examples of eclispelink when java is mapping to the result of a stored procedure object type. Assiatnce much appreciated. I plan to take it further and have the oralce object contain within it multiple complaex types.


EntityManagerFactory factory = null;
factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
EntityManager em = factory.createEntityManager();

StoredProcedureQuery query = em.createStoredProcedureQuery("customers.get_objects");
query.registerStoredProcedureParameter("theObject", YOUR_OBJECT.class, ParameterMode.OUT);

YOUR_OBJECT obj = new YOUR_OBJECT();
boolean resultSet = query.setParameter("theObject ", obj).execute();



@Entity
public class YOUR_OBJECT implements Serializable
{
@Column(name = "FIELD_ONE")
String FIELD_ONE;

@Column(name = "FIELD_TWO")
String FIELD_TWO;
......
}


Create or replace package body customers is
procedure get_objects(theObject OUT YOUR_OBJECT) is
begin
theObject:=YOUR_OBJECT('222','333');
dbms_output.put_line('hello');
end;
end customers;
/


CREATE OR REPLACE TYPE CIH.YOUR_OBJECT AS OBJECT
(
field_one varchar2(50),
field_two varchar2(100)
);
/


[EL Warning]: metamodel: 2016-09-30 17:02:54.172--The collection of metamodel types is empty. Model classes may not have been found during entity search for Java SE and some Java EE container managed persistence units. Please verify that your entity classes are referenced in persistence.xml using either <class> elements or a global <exclude-unlisted-classes>false</exclude-unlisted-classes> element
Exception in thread "main" java.lang.IllegalArgumentException: You have attempted to set a parameter value using a name of theObject that does not exist in the query string customers.get_objects.
at org.eclipse.persistence.internal.jpa.StoredProcedureQueryImpl.setParameterInternal(StoredProcedureQueryImpl.java:1091)
at org.eclipse.persistence.internal.jpa.StoredProcedureQueryImpl.setParameter(StoredProcedureQueryImpl.java:1066)
at Customers.main(Customers.java:33)
Previous Topic:EclipseLink minimum version which supports TABLE_PER_TENANT type
Next Topic:EciplseLink Caching - Strange behaviour
Goto Forum:
  


Current Time: Mon Dec 11 09:41:29 GMT 2017

Powered by FUDForum. Page generated in 0.01901 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software