Oracle Object Table Type
I have an application that I would like to map bc4j to a object type hierarchy in the database. From reading previous otn threads I'm under the impression that Domains are not used for Oracle Table Types, just for columns based on oracle types. The thread later goes on to say that for the base type (person_typ) I would map a entity object to the table(person_table) mapped to the base type. To map all the sub-types I would create new entity objects and have PersonEO subclassed into StudentEO and EmployeeEO.
I have done this and it's unclear to me when I subclass PersonEO as StudentEO how do I declare that StudentEO is of oracle object type student_typ?
I'm also having problems with inserting data into the base entity obect. Here's code:
PersonVOImpl personVo = am.getPersonVO();
PersonVORowImpl row = (PersonVORowImpl)personVo.createRow();
personVo.insertRow(row);
row.setName("Mark");
row.setPhone("911");
am.getTransaction().commit();
personVo.executeQuery();
while (personVo.hasNext()){
PersonVORowImpl personRow = (PersonVORowImpl)personVo.next();
The data gets comitted to the db correctly but when the code hits personVo.executeQuery() I get the following error:
oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.sql.STRUCT with value:Mark
at oracle.jbo.domain.TypeFactory.get(TypeFactory.java:687)
at oracle.jbo.domain.TypeFactory.getInstance(TypeFactory.java:80)
at oracle.jbo.server.OracleSQLBuilderImpl.doLoadBulkFromResultSet(OracleSQLBuilderImpl.java:1113)
at oracle.jbo.server.ViewRowImpl.populate(ViewRowImpl.java:2017)
at oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(ViewDefImpl.java:1013)
at oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(ViewObjectImpl.java:2309)
at oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(ViewObjectImpl.java:2240)
at oracle.jbo.server.QueryCollection.populateRow(QueryCollection.java:1698)
at oracle.jbo.server.QueryCollection.fetch(QueryCollection.java:1552)
at oracle.jbo.server.QueryCollection.get(QueryCollection.java:1008)
at oracle.jbo.server.ViewRowSetImpl.getRow(ViewRowSetImpl.java:2791)
at oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(ViewRowSetIteratorImpl.java:2504)
at oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed(ViewRowSetIteratorImpl.java:2368)
at oracle.jbo.server.ViewRowSetIteratorImpl.refresh(ViewRowSetIteratorImpl.java:2569)
at oracle.jbo.server.ViewRowSetImpl.notifyRefresh(ViewRowSetImpl.java:1641)
at oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:577)
at oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:611)
at oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:593)
at oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:2886)
at model.testing.main(testing.java:33)
Am I coding this correctly? I'm using jdev9032 for this. Are there any examples out there on how to correctly use bc4j with oracle object type tables?
Thanks in advance!
-Mark
Here is my ddl:
CREATE TYPE Person_typ AS OBJECT
( name VARCHAR2(30),
address VARCHAR2(100)) NOT FINAL
CREATE TABLE PERSON_TABLE OF PERSON_TYP
I map a entity object to person_table one for one and I edit the SYS_NC_OID$ property of updateable to never.
I then map a view object one for one to the entity object. The jbo trace I get when -Djbo.debugoutput=console is declared is the following (omitted everything before the db connected).[156] Successfully logged in
[157] JDBCDriverVersion: 9.0.1.4.0
[158] DatabaseProductName: Oracle
[159] DatabaseProductVersion: Personal Oracle9i Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production
[160] ViewRowSetImpl's jbo.viewlink.consistent = false (0)
[161] Column count: 3
[162] Executing SQL in generateRefAndOID...
[163] select a.oid, make_ref(PERSON_TABLE, a.oid) from (select /*+ NO_MERGE +*/ sys_op_guid() as oid from dual) a
[164] OracleSQLBuilder Executing DML on: PERSON_TABLE (Insert)
[165] INSERT INTO PERSON_TABLE(NAME,ADDRESS) VALUES (:1,:2)
[166] BaseSQLBuilder: releaseSavepoint 'BO_SP' ignored
[167] PersonVO notify COMMIT ...
[168] Column count: 3
[169] ViewObject : Created new QUERY statement
[170] SELECT REF(PersonTable), PersonTable.NAME, PersonTable.ADDRESS FROM PERSON_TABLE PersonTable
[171] LoadBulkFromResultSet failed (2)
oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.sql.STRUCT with value:Mark
java.lang.Object oracle.jbo.domain.TypeFactory.get(java.lang.Class, java.lang.Class, java.lang.Object)
TypeFactory.java:687
java.lang.Object oracle.jbo.domain.TypeFactory.getInstance(java.lang.Class, java.lang.Object)
TypeFactory.java:80
java.lang.Object[] oracle.jbo.server.OracleSQLBuilderImpl.doLoadBulkFromResultSet(oracle.jbo.server.AttributeDefImpl[], int, java.sql.ResultSet, int, oracle.jbo.server.DBTransactionImpl)
OracleSQLBuilderImpl.java:1059
void oracle.jbo.server.ViewRowImpl.populate(java.sql.ResultSet)
ViewRowImpl.java:1964
oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(oracle.jbo.server.ViewObjectImpl, oracle.jbo.server.QueryCollection, java.sql.ResultSet)
ViewDefImpl.java:1019
oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(java.lang.Object, java.sql.ResultSet)
ViewObjectImpl.java:2035
oracle.jbo.server.ViewRowImpl oracle.jbo.server.ViewObjectImpl.createInstanceFromResultSet(oracle.jbo.server.QueryCollection, java.sql.ResultSet)
ViewObjectImpl.java:1966
oracle.jbo.server.ViewRowImpl oracle.jbo.server.QueryCollection.populateRow()
QueryCollection.java:1395
boolean oracle.jbo.server.QueryCollection.fetch(int)
QueryCollection.java:1237
java.lang.Object oracle.jbo.server.QueryCollection.get(int)
QueryCollection.java:832
oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.getRow(int)
ViewRowSetImpl.java:2621
void oracle.jbo.server.ViewRowSetIteratorImpl.doFetch(int)
ViewRowSetIteratorImpl.java:2347
void oracle.jbo.server.ViewRowSetIteratorImpl.ensureRefreshed()
ViewRowSetIteratorImpl.java:2211
void oracle.jbo.server.ViewRowSetIteratorImpl.refresh(boolean, boolean)
ViewRowSetIteratorImpl.java:2412
void oracle.jbo.server.ViewRowSetImpl.notifyRefresh(boolean, boolean)
ViewRowSetImpl.java:1556
void oracle.jbo.server.ViewRowSetImpl.execute(boolean, boolean)
ViewRowSetImpl.java:548
void oracle.jbo.server.ViewRowSetImpl.executeQuery()
ViewRowSetImpl.java:564
void oracle.jbo.server.ViewObjectImpl.executeQuery()
ViewObjectImpl.java:2616
void mypackage1.testing.main(java.lang.String[])
testing.java:25
Exception in thread main
Process exited with exit code 1.
Please let me know if you need more information.
-Mark
Similar Messages
-
Only oracle object tables to create object oriented database
Can we use only oracle object tables for a database and if it can be done, can we create pure object oriented database with oracle. How it can be done?
help..
thank you..PriyashanthaHP wrote:
I have no my own definitions for OODB. There are lot in the internet. I'm asking, can't we use that OODB concept with oracle. And gave you an example with 'employee' and 'department' tables. I asked that can we create object tables for these two tables keeping their relationship
thank you..
There is no way to answer that without knowing what YOU mean by OODB.
See the database concepts doc
http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm
Nested Tables
You can create a table with a column whose datatype is another table. That is, tables can be nested within other tables as values in a column. The Oracle database server stores nested table data out of line from the rows of the parent table, using a store table that is associated with the nested table column. The parent row contains a unique set identifier value associated with a nested table instance.
Oracle Database Object-Relational Developer's Guidefor further information on nested tables
Oracle Database Advanced Application Developer's Guide -
Oracle Object Data Type and EJB
Hi, All:
Has anyone implemented a project with Oracle user-defined data type (Object
Data Type) together
with EJB? That is, using ORDBMS (Object Relational Database) together with
EJB. I am thinking to use ORDBMS together with EJB. Any information, samples
and references to this direction is appreciated.
Thanks,
John Wen
RM2M, LLC
[email protected]I''ve got a solution! I've had sql in my query
SELECT
ltrim(OPERATIVE_REPORT."orderText",11),
OPERATIVE_REPORT."resolID",
COUNT(OPERATIVE_REPORT."(usrID)order_executionUser")
FROM
OPERATIVE_REPORT
GROUP BY
ltrim(OPERATIVE_REPORT."orderText",11),
OPERATIVE_REPORT."resolID"
where orderText has clob datatype. And the reason is GROUP BY. GROUP BY deny CLOB usage. -
How to upload and checkin oracle objects(tables,functons etc)
we are using scm repository and uploading and chicking in
oracle forms and reports . want to know the steps to upload and check in oracle database objects like tables,functions,procedures etc which we already have in our database.
plz help us .Rashid,
for all structured objects you need Oracle Designer as frontend to SCM Repository. In Designer use the design editor und choose from the GENERATE Menu the item CAPTURE DESIGN OF. There you will find SERVER MODEL.
regards
Rainer -
How to user jdbc visit oracle object type function?
1ãcreate oracle object
create type cocotestparam1 as object
(id number,
name varchar(10)
2ãadd function to object
alter type cocotestparam1 add member function test1(t number) return member;
3ãcreate object body
create type body cocotestparam1 as
memeber function test1(t number)
return number
is
begin
return t;
end;
end;
how can I visit the object cocotestparam1's function?
and how can I user jdbc visit the function?CallableStatement =
"DECLARE
a person_type;
BEGIN
a.load_object(4);
? := a;
END;"
And register as an out parameter.
Edited by: michael76 on 14.07.2010 05:01 -
Performance of mapping Oracle objects to Java classes
Hi,
By retrieving some test data from Oracle database in a Java application, I compared the traditional JDBC/RDBMS solution to JPublisher-generated-classes/Oracle-object-tables solution. The underlaying Oracle database and the client environment was the same in both tests. Although the table schemas were different, they represented the same data.
It seems that the traditional JDBC/RDBMS solution is much faster. Is this a reality or did I make a mistake somewhere?
BR,
TimoI am also facing performance overhead when using Jpub generated
classes for the object types.
I am using 817 jdbc and jpub but my database is 816. I have seen
that following statements each take around 2-3 seconds to
execute. Is there any communication between driver and database
to resolve the object type ?
Please help.
cCallableStatement =
(OracleCallableStatement)m_cConnection.prepareCall("{call
list_unsync_appts_array(?,?,?,?,?,?,?,?)}");
((OracleCallableStatement)cCallableStatement).setCustomDatum(1,ct_number_arr);
cCallableStatement.registerOutParameter(2,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(3,OracleTypes.ARRAY,"T_EVENT_DETAIL_ARR");
cCallableStatement.registerOutParameter(4,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(5,OracleTypes.ARRAY,"T_EVENT_DETAIL_ARR");
cCallableStatement.registerOutParameter(6,OracleTypes.ARRAY,"T_EVENT_SUMMARY_ARR");
cCallableStatement.registerOutParameter(7,OracleTypes.ARRAY,"T_ATTENDEE_EMAIL_ARR");
cCallableStatement.registerOutParameter(8,OracleTypes.ARRAY,"T_ATTENDEE_EMAIL_ARR");
cCallableStatement.execute(); -
Hi
Did not find methods to read oracle objects.
So - is it possible to read/write objects like SDO_GEOM from ORACLE spatial ??
ToniAs noted in the release notes, this release of ODP.NET does not support Oracle Object data types.
-
Oracle Object Types vs. Table Fields
Hello, all.
I`m totally new to Oracle, and I am facing a very hard problem for me, and I would like to ask your help.
I've been working on a project which uses Oracle Object Types, from a database of a legacy system.
I did not know Oracle Objects until 5 minutes ago, so sorry If I say something stupid:
Per my understanding, a Oracle Object Type can be formed by fields like myField varchar(200)... and fields from an existing table or view.
I have a lot of objects on my system and I need to map each field and its respective table or view that compose each object.
Does anyone have a query for that? I think it should be common, but I could not find anything at google (maybe I don`t which terms use to find...)
I would be very thankful if somebody could help (save) me.
Thanks in advance.
PauloFirst, it would help if you post what you object types look like.
I'm assuming they may look something like this:
SQL> create TYPE emp_type AS OBJECT
2 (emp_id NUMBER,
3 name VARCHAR2(20));
4 /
Type created.
SQL> create TYPE emp_tab IS TABLE OF emp_type;
2 /
Type created.
SQL> create or replace package emp_test as
2 procedure get_emps;
3 end emp_test ;
4 /
Package created.
SQL> create or replace package body emp_test as
2 employees emp_tab := emp_tab();
3 procedure get_emps as
4 g_rc sys_refcursor;
5 BEGIN
6 employees.EXTEND(2);
7 employees(1) := emp_type (1, 'John Smith');
8 employees(2) := emp_type (2, 'William Jones');
9 OPEN g_rc FOR
10 SELECT * FROM TABLE (CAST (employees AS emp_tab));
11 END get_emps ;
12 end emp_test ;
13 /
Package body created. -
Working with oracle object type tables
Hi,
I've created a table which only contains Oracle object types (e.g. CREATE TABLE x OF <...>). When I create an Entity for this table using the Entity wizard, I end up with an entity with the attributes of the base object type and two special attributes REF$ (reference to the object type instance) and SYS_NC_OID$ (unique object identifier). The REF$ attribute is on the Java side of type oracle.jbo.domain.Ref and the other attribute is on the Java side a simple String.
It seems this only allows me to save objects of the base type in this table. First of all in my situation this is also impossible because the base type is not instantiable. What I do want is to save several different subtypes into this table using the BC4J custom domain mechanism. Is there any way to make this possible? I first thought I could maybe do something with the special REF$ attribute, but this doesn't seem te case. So I might need to override most of the EntityImpl methods, like doUML, remove etc. Am I right? And does anyone have any hints on how to do this?
Regards,
PeterPeter:
Hi,
I've created a table which only contains Oracle
object types (e.g. CREATE TABLE x OF <...>).
When I create an Entity for this table using the
Entity wizard, I end up with an entity with the
attributes of the base object type and two special
attributes REF$ (reference to the object type
instance) and SYS_NC_OID$ (unique object identifier).
The REF$ attribute is on the Java side of type
oracle.jbo.domain.Ref and the other attribute is on
the Java side a simple String.
It seems this only allows me to save objects of the
base type in this table. First of all in my situation
this is also impossible because the base type is not
instantiable. What I do want is to save several
different subtypes into this table using the BC4J
custom domain mechanism. Is there any way to make
this possible? Sorry, but this is not supported out of the box.
Since you have an object table, you wouldn't use domains to achieve this. Instead, you would have a superclass and subclass entity objects, e.g., PersonEO subclassed into StudentEO and EmployeeEO.
I first thought I could maybe do
something with the special REF$ attribute, but this
doesn't seem te case. So I might need to override
most of the EntityImpl methods, like doUML, remove
etc. Am I right? And does anyone have any hints on
how to do this?
If you want, you can try this by overridding EntityImpl's:
protected StringBuffer buildDMLStatement(int operation,
AttributeDefImpl[] allAttrs,
AttributeDefImpl[] retCols,
AttributeDefImpl[] retKeys,
boolean batchMode)
and
protected int bindDMLStatement(int operation,
PreparedStatement stmt,
AttributeDefImpl[] allAttrs,
AttributeDefImpl[] retCols,
AttributeDefImpl[] retKeys,
HashMap retrList,
boolean batchMode) throws SQLException
Handle the case when operation == DML_INSERT.
There, build an insert statement with substitutable row, e.g.:
INSERT INTO persons VALUES (person_t('Bob', 1234));
INSERT INTO persons VALUES (employee_t('Joe', 32456, 12, 100000));
where person_t and employee_t are database types and you are invoking the respective constructor.
Thanks.
Sung -
Require help on Array of Nested tables and Oracle Object type
Hi All,
I have a scenario where I have some millions of records received from a flat file and the record is stored in Table as below:
Tablename: FILE_RECORD
Rows:
FILE_REG_ID = 1
RECORD_NBR = 1
PROCESSED_IND = U
RECORD= 00120130326006A
FILE_REG_ID = 1
RECORD_NBR = 2
PROCESSED_IND = U
RECORD= 00120130326003
1) I have to read these records at once and
a) Split the RECORD column to get various other data Eg: Fld1=001, Fld2=20130326, Fld3 = 003
b) send as an Array to Java.
2) Java will format this into XML and sent to other application.
3) The other application returns a response as Successful or Failure to Java in XML
4) Java will send RECORD_NBR and the corresponding response as Success or Failure back to PLSQL
5) PLSQL should match the RECORD_NBR and update the PROCESSED_IND = P.
I 'm able to achieve this using SQL Table type by creating a TYPE for Each of the fields (Flds) however the problem is Java cannot Access the parameters as the TYPE are of COLUMN Types
Eg: For RECORD_NBR
SUBTYPE t_record_nbr IS FILE_RECORD.T010_RECORD_NBR%TYPE;
Can you please let me know how I can achieve this to support Java, I know one way that is by creating an OBJECT TYPE and a TABLE of the OBJECT TYPE.
Eg: T_FILE_RECORD_REC IS OBJECT
FILE_REG_ID number(8), RECORD_NBR number (10), PROCESSED_IND varchar2(1), RECORD varchar(20)
Create type T_FILE_RECORD_TAB IS TABLE OF T_FILE_RECORD_REC
However I'm facing a problem to populate an Array of records, I know I'm missing something important. Hence please help.
It would be helpful to provide some guidelines and suggestions or Pseudo or a Code to achieve this. Rest all I can take up further.
Thanks in advance,I know once way that is creating a OBJECT TYPE and a TABLE of OBJECT TYPE, howeve I feel I'm missing something to achieve this.You're right, you need SQL object types created at the database level. Java doesn't know about locally defined PL/SQL types
However you can do without all this by creating the XML directly in PL/SQL (steps 1+2) and passing the document to Java as XMLType or CLOB.
Are you processing the records one at a time? -
How to use Oracle Table Type values in Select Statement.
Hi,
I am fetching initial set of values into Oracle Table of Records Type and want to use list of values in the Select statement.
For example, try something like the following:
TYPE t_record IS RECORD (
ID TABLEA.ID%type,
NO TABLEA.NO%type,
v_record t_record;
TYPE t_table IS TABLE OF v_record%TYPE;
v_table t_table;
-- Code to populate the values in v_table here.
SELEC ID,NO, BULK COLLECT INTO <some other table variabes here> FROM TABLEA
WHERE ID IN v_table(i).ID;
I want to know how to use the values from Oracle Table Type in the Select Statement.Something like this:
create or replace type t_record as object (
id number,
no number
CREATE or replace type t_table AS TABLE OF t_record;
set serveroutput on
declare
v_table t_table := t_table();
v_t1 t_table := t_table();
begin
v_table.extend(1);
v_table(1).ID := 1;
v_table(1).No := 10;
v_table.extend(1);
v_table(2).ID := 2;
v_table(2).ID := 20;
SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
from TableA
FROM TABLEA
WHERE ID IN (select t.ID from table(v_Table) t);
for i in 1..v_t1.count loop
dbms_output.put_line(v_t1(i).ID);
dbms_output.put_line(v_t1(i).No);
end loop;
end;
/Untested!
P;
Edited by: bluefrog on Mar 5, 2010 5:08 PM -
Oracle object, nested table on a subtype
Hello,
Is it possible to have a nested table on a subtype? If it is, can someone help me?
Here is what I need help for:
I have a supertype WORK, that have:
multivalued attribute ADDRESS
a attribute NAME, also the primary key
The subtype is called EMPLOYEE, that have:
multivalued attribute SPECIALTY
a attribute NAME
a attribute SSN
So far have I got:
//* The supertype *//
create or replace type ADRESS_TP as object(
ADRESS varchar2(50));
create or replace type ADRESSTP as table of ADRESS_TP;
create or replace WORK_TP as object(
NAME varchar2(30),
ADRESS ADRESSTP)
NOT FINAL;
create table WORK_TBL of WORK_TP(
Primary key(NAME))
nested table ADRESS store as NT_ADR(
(Primary key(nested_table_id, ADRESS))
organization index compress);
//* The subtype *//
create or replace type SPECIALTY_TP as object(
ADRESS varchar2(50));
create or replace type SPECIALTYTP as table of SPECIALTY_TP;
create or replace EMPLOYEE_TP under work_tp(
NAME varchar2(30),
SSN number)
FINAL;
The multivalued attribute SPECIALTYTP has to be declared in WORK_TBL have I been told, but how can I do that?
I'm using oracle 9iI'm not really sure what your problem is. In future please be specific about what it is you are trying to do and what it is that is not working. If it's an error please give us the error message and number. It's not the behaviour you are expecting please describe what it does. If it's that you simply don't understand please say what you don't understand.
I go on like this because the code you have posted is somewhat confusing. The Oracle object-oriented implementation is not quite complete so that makes it hard for people who know OO but don't know Oracle. Whereas most of us who know Oracle aren't expert in OO. Also, I think you should be slightly more inventive in your names: there's so many things called ADRESS it's easy to get them tangled up.
Anyway, here's my guess at what I think your problem is....
SQL> CREATE OR REPLACE TYPE adress_t AS OBJECT(
2 line1 VARCHAR2(50)
3 ,line2 VARCHAR2(50)
4 ,postcode VARCHAR2(8));
5 /
Type created.
SQL>
SQL> CREATE OR REPLACE TYPE adress_nt AS TABLE OF adress_t;
2 /
Type created.
SQL> CREATE OR REPLACE TYPE work_t AS OBJECT(
2 name VARCHAR2(30),
3 adresses adress_nt)
4 NOT FINAL;
5 /
Type created.
SQL> CREATE TABLE work_tbl OF work_t
2 NESTED TABLE adresses STORE AS adress_ntab
3 /
Table created.
SQL> CREATE OR REPLACE TYPE specialty_t AS OBJECT(
2 description VARCHAR2(50));
3 /
Type created.
SQL> CREATE OR REPLACE TYPE specialty_nt AS TABLE OF specialty_t;
2 /
Type created.
SQL>
SQL> ALTER TYPE work_t ADD ATTRIBUTE specialities specialty_nt CASCADE
2 /
Type altered.
SQL> DESC work_tbl
Name Null? Type
NAME VARCHAR2(30)
ADRESSES ADRESS_NT
SPECIALITIES SPECIALTY_NT
SQL> Cheers, APC -
Invoking stored procedure that returns array(oracle object type) as output
Hi,
We have stored procedures which returns arrays(oracle type) as an output, can anyone shed some light on how to map those arrays using JPA annotations? I tried using jdbcTypeName but i was getting wrong type or argument error, your help is very much appreciated. Below is the code snippet.
JPA Class:
import java.io.Serializable;
import java.sql.Array;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.eclipse.persistence.annotations.Direction;
import org.eclipse.persistence.annotations.NamedStoredProcedureQuery;
import org.eclipse.persistence.annotations.StoredProcedureParameter;
* The persistent class for the MessagePublish database table.
@Entity
@NamedStoredProcedureQuery(name="GetTeamMembersDetails",
procedureName="team_emp_maintenance_pkg.get_user_team_roles",
resultClass=TeamMembersDetails.class,
returnsResultSet=true,
parameters={
@StoredProcedureParameter(queryParameter="userId",name="I_USER_ID",direction=Direction.IN,type=Long.class),
@StoredProcedureParameter(queryParameter="employeeId",name="I_EMPLOYEEID",direction=Direction.IN,type=Long.class),
@StoredProcedureParameter(queryParameter="TEAMMEMBERSDETAILSOT",name="O_TEAM_ROLES",direction=Direction.OUT,jdbcTypeName="OBJ_TEAM_ROLES"),
@StoredProcedureParameter(queryParameter="debugMode",name="I_DEBUGMODE",direction=Direction.IN,type=Long.class)
public class TeamMembersDetails implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private long userId;
private List<TeamMembersDetailsOT> teamMembersDetailsOT;
public void setTeamMembersDetailsOT(List<TeamMembersDetailsOT> teamMembersDetailsOT) {
this.teamMembersDetailsOT = teamMembersDetailsOT;
public List<TeamMembersDetailsOT> getTeamMembersDetailsOT() {
return teamMembersDetailsOT;
Procedure
PROCEDURE get_user_team_roles (
i_user_id IN ue_user.user_id%TYPE
, o_team_roles OUT OBJ_TEAM_ROLES_ARRAY
, i_debugmode IN NUMBER :=0)
AS
OBJ_TEAM_ROLES_ARRAY contains create or replace TYPE OBJ_TEAM_ROLES_ARRAY AS TABLE OF OBJ_TEAM_ROLES;
TeamMembersDetailsOT contains the same attributes defined in the OBJ_TEAM_ROLES.A few things.
You are not using a JDBC Array type in your procedure, you are using a PLSQL TABLE type. An Array type would be a VARRAY in Oracle. EclipseLink supports both VARRAY and TABLE types, but TABLE types are more complex as Oracle JDBC does not support them, they must be wrapped in a corresponding VARRAY type. I assume your OBJ_TEAM_ROLES is also not an OBJECT TYPE but a PLSQL RECORD type, this has the same issue.
Your procedure does not return a result set, so "returnsResultSet=true" should be "returnsResultSet=false".
In general I would recommend you change your stored procedure to just return a select from a table using an OUT CURSOR, that is the easiest way to return data from an Oracle stored procedure.
If you must use the PLSQL types, then you will need to create wrapper VARRAY and OBJECT TYPEs. In EclipseLink you must use a PLSQLStoredProcedureCall to access these using the code API, there is not annotation support. Or you could create your own wrapper stored procedure that converts the PLSQL types to OBJECT TYPEs, and call the wrapper stored procedure.
To map to Oracle VARRAY and OBJECT TYPEs the JDBC Array and Struct types are used, these are supported using EclipseLink ObjectRelationalDataTypeDescriptor and mappings. These must be defined through the code API, as there is currently no annotation support.
I could not find any good examples or doc on this, your best source of example is the EclipseLink test cases in SVN,
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/plsql/
http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/customsqlstoredprocedures/
James : http://www.eclipselink.org -
Concurrency and Oracle Object Types
Hi All,
I have a question regarding Concurrent usage of an Object type in Oracle.
I have a java program which calls an Oracle stored proc with the object's table type as IN parameter. In my stored proc, I am populating an Oracle Object with data received from java and retrieving some data based on that.
My java program can be invoked concurrently by 500 users at the same time - the application is built to handle that request load.
Now in Oracle, if a bunch of requests are received at the same, would Oracle create multiple instances of this object type that would be usage to the multiple stored proc invocations? Or would there be a prob of concurrency?
If multiple instance creation is not supported, is there some alternative I can use?
My code roughly resembles:
Object:
contains two columns - name, age
Stored proc - logic to retrieve and return data from a table based on the name, age received.
When a bunch of requests access the stored proc simultaneously, will a bunch of instnaces of the object type get created? Or would there be a scenario where the object is common to all requests and hence data from one request would be conflicted due to data from another request?Hi Wiiliam
Sorry for the late acknowledgement (i dozed off!).. Thanks for the response. So the private instance specific to a session ensure that theres no conflict between multiple requests to the same stored proc and hence no conflict of data... Great
Chaitanya -
Managing statistics for object collections used as table types in SQL
Hi All,
Is there a way to manage statistics for collections used as table types in SQL.
Below is my test case
Oracle Version :
SQL> select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for IBM/AIX RISC System/6000: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> Original Query :
SELECT
9999,
tbl_typ.FILE_ID,
tf.FILE_NM ,
tf.MIME_TYPE ,
dbms_lob.getlength(tfd.FILE_DATA)
FROM
TG_FILE tf,
TG_FILE_DATA tfd,
SELECT
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) tbl_typ
WHERE
tf.FILE_ID = tfd.FILE_ID
AND tf.FILE_ID = tbl_typ.FILE_ID
AND tfd.FILE_ID = tbl_typ.FILE_ID;
Elapsed: 00:00:02.90
Execution Plan
Plan hash value: 3970072279
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 194 | 4567 (2)| 00:00:55 |
|* 1 | HASH JOIN | | 1 | 194 | 4567 (2)| 00:00:55 |
|* 2 | HASH JOIN | | 8168 | 287K| 695 (3)| 00:00:09 |
| 3 | VIEW | | 8168 | 103K| 29 (0)| 00:00:01 |
| 4 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 8168 | 16336 | 29 (0)| 00:00:01 |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | TG_FILE | 565K| 12M| 659 (2)| 00:00:08 |
| 7 | TABLE ACCESS FULL | TG_FILE_DATA | 852K| 128M| 3863 (1)| 00:00:47 |
Predicate Information (identified by operation id):
1 - access("TF"."FILE_ID"="TFD"."FILE_ID" AND "TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
2 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
Statistics
7 recursive calls
0 db block gets
16783 consistent gets
16779 physical reads
0 redo size
916 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed Indexes are present in both the tables ( TG_FILE, TG_FILE_DATA ) on column FILE_ID.
select
index_name,blevel,leaf_blocks,DISTINCT_KEYS,clustering_factor,num_rows,sample_size
from
all_indexes
where table_name in ('TG_FILE','TG_FILE_DATA');
INDEX_NAME BLEVEL LEAF_BLOCKS DISTINCT_KEYS CLUSTERING_FACTOR NUM_ROWS SAMPLE_SIZE
TG_FILE_PK 2 2160 552842 21401 552842 285428
TG_FILE_DATA_PK 2 3544 852297 61437 852297 852297 Ideally the view should have used NESTED LOOP, to use the indexes since the no. of rows coming from object collection is only 2.
But it is taking default as 8168, leading to HASH join between the tables..leading to FULL TABLE access.
So my question is, is there any way by which I can change the statistics while using collections in SQL ?
I can use hints to use indexes but planning to avoid it as of now. Currently the time shown in explain plan is not accurate
Modified query with hints :
SELECT
/*+ index(tf TG_FILE_PK ) index(tfd TG_FILE_DATA_PK) */
9999,
tbl_typ.FILE_ID,
tf.FILE_NM ,
tf.MIME_TYPE ,
dbms_lob.getlength(tfd.FILE_DATA)
FROM
TG_FILE tf,
TG_FILE_DATA tfd,
SELECT
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
tbl_typ
WHERE
tf.FILE_ID = tfd.FILE_ID
AND tf.FILE_ID = tbl_typ.FILE_ID
AND tfd.FILE_ID = tbl_typ.FILE_ID;
Elapsed: 00:00:00.01
Execution Plan
Plan hash value: 1670128954
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 194 | 29978 (1)| 00:06:00 |
| 1 | NESTED LOOPS | | | | | |
| 2 | NESTED LOOPS | | 1 | 194 | 29978 (1)| 00:06:00 |
| 3 | NESTED LOOPS | | 8168 | 1363K| 16379 (1)| 00:03:17 |
| 4 | VIEW | | 8168 | 103K| 29 (0)| 00:00:01 |
| 5 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 8168 | 16336 | 29 (0)| 00:00:01 |
| 6 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 7 | TABLE ACCESS BY INDEX ROWID | TG_FILE_DATA | 1 | 158 | 2 (0)| 00:00:01 |
|* 8 | INDEX UNIQUE SCAN | TG_FILE_DATA_PK | 1 | | 1 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | TG_FILE_PK | 1 | | 1 (0)| 00:00:01 |
| 10 | TABLE ACCESS BY INDEX ROWID | TG_FILE | 1 | 23 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
8 - access("TFD"."FILE_ID"="TBL_TYP"."FILE_ID")
9 - access("TF"."FILE_ID"="TBL_TYP"."FILE_ID")
filter("TF"."FILE_ID"="TFD"."FILE_ID")
Statistics
0 recursive calls
0 db block gets
16 consistent gets
8 physical reads
0 redo size
916 bytes sent via SQL*Net to client
524 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
2 rows processed
Thanks,
BThanks Tubby,
While searching I had found out that we can use CARDINALITY hint to set statistics for TABLE funtion.
But I preferred not to say, as it is currently undocumented hint. I now think I should have mentioned it while posting for the first time
http://www.oracle-developer.net/display.php?id=427
If we go across the document, it has mentioned in total 3 hints to set statistics :
1) CARDINALITY (Undocumented)
2) OPT_ESTIMATE ( Undocumented )
3) DYNAMIC_SAMPLING ( Documented )
4) Extensible Optimiser
Tried it out with different hints and it is working as expected.
i.e. cardinality and opt_estimate are taking the default set value
But using dynamic_sampling hint provides the most correct estimate of the rows ( which is 2 in this particular case )
With CARDINALITY hint
SELECT
/*+ cardinality( e, 5) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 1467416936
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 10 | 29 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 5 | 10 | 29 (0)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
With OPT_ESTIMATE hint
SELECT
/*+ opt_estimate(table, e, scale_rows=0.0006) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Execution Plan
Plan hash value: 4043204977
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5 | 485 | 29 (0)| 00:00:01 |
| 1 | VIEW | | 5 | 485 | 29 (0)| 00:00:01 |
| 2 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 5 | 10 | 29 (0)| 00:00:01 |
| 3 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
With DYNAMIC_SAMPLING hint
SELECT
/*+ dynamic_sampling( e, 5) */*
FROM
TABLE
SELECT
CAST(TABLE_ESC_ATTACH(OBJ_ESC_ATTACH( 9999, 99991, 'file1.png', NULL, NULL, NULL),
OBJ_ESC_ATTACH( 9999, 99992, 'file2.png', NULL, NULL, NULL)) AS TABLE_ESC_ATTACH)
FROM
dual
) e ;
Elapsed: 00:00:00.00
Execution Plan
Plan hash value: 1467416936
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 2 | 4 | 11 (0)| 00:00:01 |
| 1 | COLLECTION ITERATOR CONSTRUCTOR FETCH| | 2 | 4 | 11 (0)| 00:00:01 |
| 2 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
Note
- dynamic sampling used for this statement (level=2)I will be testing the last option "Extensible Optimizer" and put my findings here .
I hope oracle in future releases, improve the statistics gathering for collections which can be used in DML and not just use the default block size.
By the way, are you aware why it uses the default block size ? Is it because it is the smallest granular unit which oracle provides ?
Regards,
B
Maybe you are looking for
-
When trying to install iTunes 8.2.1, I get a Mobile Device Support error
When I run the iTunes 8.2.1 Installer, everything works fine until it starts the actual install process, when it prints out the error "run preupgrade script for Apple Mobile Device Support. Contact the software manufacturer for assistance." I have so
-
I had a FrameMaker file that has gone through several revisions. In its last revision it accidentally had an older version of a pdf file created on a Mac on one of the pages. The FrameMaker file distilled fine with Acrobat 8 but had issues under Acro
-
If you trashed all your music in your itunes and emptied the trash can you get them back?
I have trashed all the "orginial files" of my itunes songs and emptied the trash. I did not know I was deleting the files when I did it. I thought they would still play in my itunes but it just pops up and says the original file for this song cannot
-
HT204022 Can I prevent photos from being deleted accidentally?
Sometimes my kids will delete photos from photo stream, is there a way to lock them so I can save them first?
-
Installer could not validate the contents of the "BaseSystem"
Reference the quite volumnious "Installer could not validate the contents of the 'BaseSystem'". Given the dual-layer DVD inserted in a single-layer SuperDrive fact, I tried installing just the Base System with nothing else and got the same error. On