How to save array of UserType in Oracle using Hibernate.

Ads

 
 

Share on Google+Share on Google+

shaik shafak
How to save array of UserType in Oracle using Hibernate.
0 Answer(s)      6 years and 4 months ago
Posted in : 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.

Ads
View Answers
Ads









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...; //setters and getters } public class EmpAddressArrTY implements UserType
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
Hibernate save()
This tutorial explain how save() works in hibernate
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
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
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
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
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 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 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
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
Hibernate save Example - Rose India Hibernate 4 tutorials
in Eclipse tutorial page. How to save objects in Hibernate? Hibernate is very easy...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 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 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 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 create primary key using hibernate?
How to create primary key using hibernate?  Hi, How to create primary key using hibernate? Thanks
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
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 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... this. i am able to read the csv file using this code if (window.XMLHttpRequest
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 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 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
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 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 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
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
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

Ads

 
Advertisement null

Ads