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:
pojos.AddressVO@83b1b
Thanks in advance.
View Answers
Related Tutorials/Questions & Answers:
Advertisements
how to save uploaded image in database using javascripthow 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 JAVAHOW 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
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for hibernate-usertype version 0.1.0 com.qoomon:
hibernate-
usertype:0.1.0 Java library in your project..
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr
Dependency for
hibernate-
usertype..., SBT,
Ivy, Grape, Leiningen and Buildr Dependency for
hibernate-
usertype 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
Hibernate- Oracle connection - HibernateHibernate-
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 Hibernate oracle dialectHibernate 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
using arrayusing array Circular left shift
array element by one position
using arrayusing array Circular left shift
array element by one position
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.
the
array contains names of people
using arrayusing array display 10 digit number
using array and print pyramid.
1
1
1 1
1 1 1 1
1 1 1 1
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 save Example - Rose India Hibernate 4 tutorials in Eclipse tutorial page.
How to
save objects in
Hibernate?ADS_TO_REPLACE_1...
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 get data from Oracle database using JSPHow 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... data from the database like
oracle), I have created one jsp program like
using arrayusing array read 10 digit number and display (star
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
save list of objects in Spring and hibernatesave 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