How to save array of UserType in Oracle using Hibernate.

How to save array of UserType in Oracle using Hibernate.

Hi How to save array of UserType in Oracle using Hibernate.

CREATE OR REPLACE TYPE ADDRESS_TY AS OBJECT ( plot number(4), street varchar2(20), city varchar2(20) );

CREATE OR REPLACE TYPE ADDRESSTYARR AS VARRAY(100) OF ADDRESS_TY;

Create Table EMPLOYEEARR(EMPID VARCHAR2(10),ADDRESSES ADDRESSTY_ARR);

EmpAddress.hbm.xml

<class name="EmpAddressArr" table="EMPLOYEE_ARR">
  <!-- cache usage="read-only"/-->
      <id name="empid" column="EMPID" type="string"/>
      <property name="empAddressArray" column="ADDRESSES" type= "pojos.EmpAddressArrTY"/>  </class>

public class AddressVO {

      private int plot;
      private String street;
      private String city;
      //setters and getters
}

public class EmpAddressArrTY implements UserType {

//implemented all other required methods public void nullSafeSet(PreparedStatement arg0, Object arg1, int arg2)
                  throws HibernateException, SQLException {
            if(arg1==null){
                  ArrayDescriptor arrdesc=new ArrayDescriptor( "ADDRESS_TY_ARR",arg0.getConnection());
                  ARRAY array =new ARRAY(arrdesc, arg0.getConnection(), null);
                  arg0.setObject(arg2,array);
            }else{
                  HashSet set = (HashSet)arg1;
                  Object [] objs = (Object[])set.toArray();
                  AddressVO []addr = new AddressVO[objs.length];
                  for(int i=0;i<objs.length;i++)
                  {   addr[i] = (AddressVO)objs[i];   }

                  ArrayDescriptor arrdesc=new ArrayDescriptor( "ADDRESS_TY_ARR",arg0.getConnection());
                  ARRAY array =new ARRAY(arrdesc, arg0.getConnection(), addr);
                  arg0.setArray(arg2,array);
            }
      }
}

Getting following exception: java.sql.SQLException: Fail to convert to internal representation: [email protected]

Thanks in advance.

View Answers









Related Tutorials/Questions & Answers:
How to save array of UserType in Oracle using Hibernate.
How to save array of UserType in Oracle using Hibernate.  Hi How to save array of UserType in Oracle using Hibernate. CREATE OR REPLACE TYPE... and getters } public class EmpAddressArrTY implements UserType { //implemented
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
Advertisements
how to save images in oracle using JSP
how to save images in oracle using JSP  how to insert images in oracle using jsp
How to save database data into excelsheet using hibernate
How to save database data into excelsheet using hibernate  How to save database data into excelsheet using hibernate
Version of com.qoomon>hibernate-usertype dependency
List of Version of com.qoomon>hibernate-usertype dependency
Maven Dependency hibernate-usertype >> 0.1.1
You should include the dependency code given in this page to add Maven Dependency of com.qoomon >> hibernate-usertype version0.1.1 in your project
Maven Dependency hibernate-usertype >> 0.1.0
You should include the dependency code given in this page to add Maven Dependency of com.qoomon >> hibernate-usertype version0.1.0 in your project
Using Hibernate Functionality and pass it on to the JCAPS Oracle eWay - Hibernate
Using Hibernate Functionality and pass it on to the JCAPS Oracle eWay  Hi All, I need to use the Existing Hibernate API's and pass it on to the JCAPS oracle eWay to persist the Data. As the present Application is using
Hibernate save()
This tutorial explain how save() works in hibernate
how to save uploaded image in database using javascript
how to save uploaded image in database using javascript  Please can you tell me how to store uploaded image in database using java I'll use the upload code as extArray = new Array(".gif", ".jpg", ".png"); function LimitAttach
HOW TO SAVE XML INTO MYSQL AND RETRIEVE IT USING JAVA
HOW TO SAVE XML INTO MYSQL AND RETRIEVE IT USING JAVA  H ello, i have an xml code, i need to save it into mysql 5.5 server database using java. i also want to be able to retrieve it as well. please note that i want it saved
Hibernate- Oracle connection - Hibernate
Hibernate- Oracle connection  In Eclipse I tried Windows -->... on databaseconnection --> New Oracle Added ojdbc14 Jar file path UID...) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Please let me know How
How to create a databas locally in our system using Oracle 10g????
How to create a databas locally in our system using Oracle 10g????  How to create a databas locally in our system using Oracle 10g
How to delete objects using Hibernate?
How to delete objects using Hibernate?  Hi, How to delete objects using Hibernate? I want to delete an object (record) in table. Thanks   Hi, Hibernate Session API provides function to delete object. For deleting
Hibernate oracle dialect
Hibernate oracle dialect  What is the the Hibernate oracle dialect?   Hi, Here is the Hibernate dialect for oracle database...({}); org.hibernate.dialect.OracleDialect Read more at Dialect in Hibernate. Thanks
Hibernate One to many XML mapping array Example
In this section, you will learn how to do one to many mapping using array to retain mapping order in Hibernate
how to store image in oracle express edition using servlet
how to store image in oracle express edition using servlet  strong text how to store image in oracle express edition using servlet?   Please visit the following link: Servlet Insert image into MySQL database
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java Programming Language. I am trying to create small application using Array functions. The problem is that how to use binary search array in Java. Please give
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which... be inserted into oracle database.. please help me sir...   hi friend
How to download and save a file from Internet using Java?
How to download and save a file from Internet using Java?  How to download and save a file from Internet using Java
how to create a zip by using byte array
how to create a zip by using byte array  hi, How to convert byte array to zip by using java program.can u plz provide it...... Thanks, krishna
how to generate reports from oracle database using jsp and ajax code
how to generate reports from oracle database using jsp and ajax code  Hai masters i am new to this Java world. my team leader ask me to generate sales report data from oracle database to jsp page please any one know how to do
how to load a table of data from oracle, to a jsp page using hashmap.
how to load a table of data from oracle, to a jsp page using hashmap.  I have a jsp page which ask for project ID,team name,member name according to this data i have to retrieve their details from the database(oracle). I have
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
How i upload file and save that record in database using JSP?
How i upload file and save that record in database using JSP?  Hi All, I m the beginner in JSP and I want to upload the file and store that file and some other form data in MySQL database. Ex. There is one employee detail form
How to save form data to a csv file using jquery or ajax
How to save form data to a csv file using jquery or ajax  Please let me know more about how to do this or please suggest me any sites to learn... the csv file using this code if (window.XMLHttpRequest) {// code for IE7
How to save excel sheet into mysql database using blob or clob
How to save excel sheet into mysql database using blob or clob  Hi All, I am new to java and i need to upload excel sheet to mysql, please suggest... know to go further, which one should i use BLOB or CLOB ? I have tried using
how to save html form data into .csv file using only jsp.
how to save html form data into .csv file using only jsp.  Dear all, I am developing a website only using jsp and html. i need to save the form data into a .csv file using jsp. can anyone give me any sample solution or tutorial
Hibernate save Example - Rose India Hibernate 4 tutorials
in Eclipse tutorial page. How to save objects in Hibernate? (adsbygoogle...Hibernate save Example - Rose India Hibernate 4 tutorials In the last section you have learned how to create Hibernate application in Eclipse. We have also
how to creating hbm files in hibernate using Myeclipse
how to creating hbm files in hibernate using Myeclipse  how to creating hbm files in hibernate using Myeclipse
How to Upload a file directly to Oracle database using JSP or Servlets?
How to Upload a file directly to Oracle database using JSP or Servlets?  Hi I want to upload a file(csv or excel) to Oracle 10g Database using JSP... to Oracle Database</h2> <form id="form1" enctype="multipart/form
How to create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks, (adsbygoogle = window.adsbygoogle || []).push
How to create binary search tree using an array?
How to create binary search tree using an array?  hello people, pls guide me on the topic above. i have an string array, i want to make a binary search tree based on data inside this array. (adsbygoogle
How to get data from Oracle database using JSP
How to get data from Oracle database using JSP  hello i have a simple problem in jsp in the sense to get data from the database like oracle . I have... the database like oracle), I have created one jsp program like this *<@ page
using array
using array  Circular left shift array element by one position
using array
using array  Circular left shift array element by one position
how to develope a struts application using hibernate?
how to develope a struts application using hibernate?  Hi Folks, I... and password should validate against database using hibernate framework.../struts-hibernate/ http://www.roseindia.net/struts
servelet connectivity with oracle using procedure
servelet connectivity with oracle using procedure   kindly elaborate how servlet code connect to oracle br using procedure
How to Create a ByteBuffer using Byte Array in java.
How to create a ByteBuffer using Byte Array in java.      ..., we will discuss how to creates a buffer using byte array. The ByteBuffer ... Description static ByteBuffer wrap(byte array
using array
using array  display 10 digit number using array and print pyramid. 1 1 1 1 1 1 1 1 1 1 1 1
save list of objects in Spring and hibernate
save list of objects in Spring and hibernate  I use a javascript which add dynamic rows with values in jsp. Now i want to save these multiple values using spring and hibernate. Thanks for help (adsbygoogle
how to Insert Array Values Into Separate Rows using java?
how to Insert Array Values Into Separate Rows using java?  how to Insert Array Values Into Separate Rows using java?  class...) { String array[][]={{"1","Angel","Delhi"},{"2","John","Chennai"},{"3","William
how to convert string to char array in java without using tochararray
how to convert string to char array in java without using tochararray ...() function. how to convert string to char array in java without using... to char array in java without using tochararray: package my.app; public
using array
using array  transpose a matrix
using array
using array  transpose a matrix
using array
using array  column wise total of a matrix
oracle database backup using jsp
oracle database backup using jsp   I want to take the backup of oracle database.I want to write the code in jsp ,so that when the page is loaded... this task? If possible how can it be done
using array
using array  read 10 digit number and display (star
how to download oracle 9i
how to download oracle 9i  how to download oracle 9i
Record and Save Video using Java
Record and Save Video using Java  How to record video(webcam) and save it using Java.?? Its really urgent

Ads