-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: Using Hibernate with Oracle STRUCT or ARRAY of Objects
PostPosted: Wed Jul 02, 2008 1:31 am 
Newbie

Joined: Wed Jul 02, 2008 1:19 am
Posts: 3
Hi,

I am using the the following for my development work:

Hibernate version: 3.1.3
Oracle version: 9i
JDK version: 1.5
Application Server: Weblogic 9.2

I need to pass an array of records (with multiple columns of different data types) to my stored procedure (defined in Oracle) for processing.

I have seen sample for doing this using JDBC and Oracle Collections (using STUCT & ARRAY objects) . However I waould like to pass this set of multiple records using Hibernate. So far I could not get any help on this area.

Can anyone suggest/help me in this regard? Any sample code / reference would be very helpful

Any help would be really appreciated.

Thanks in advance.
Adish


Top
 Profile  
 
 Post subject: Re: Using Hibernate with Oracle STRUCT or ARRAY of Objects
PostPosted: Wed Jul 02, 2008 10:35 am 
Newbie

Joined: Wed Jul 02, 2008 1:19 am
Posts: 3
Hi,

Can anyone please help me on this?

Thanks in Advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 04, 2008 11:13 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
The executeUpdate method is great for doing batch updates.

Alternatively, you could just loop through the array within an open Session. This will minimize the number of transactions that are needed.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 07, 2008 3:11 am 
Newbie

Joined: Wed Jul 02, 2008 1:19 am
Posts: 3
Hi Cameron,
Thanks a lot replying.
However, I am looking out for some help for calling stored procedure accepting array of objects through hibernate

In the mean time I have managed to do this with a JDBC call with ARRAY Descriptor .Here I only use hibernate to get connection.
Thanks


Top
 Profile  
 
 Post subject: Re: Using Hibernate with Oracle STRUCT or ARRAY of Objects
PostPosted: Wed Jan 28, 2015 10:24 am 
Newbie

Joined: Wed Jan 28, 2015 10:11 am
Posts: 1
Hi,

I am also trying to Pass Array of Object to Oracle Stored procedure. I have done it successfully using JDBC but when I am trying to do the same with JPA + Hibernate, I am getting below exception. I have no clue what went wrong.

javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not serialize
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1389)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1317)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)
at demo.dao.repositories.PermissionRepositoryImpl.insertPermissionBySP(PermissionRepositoryImpl.java:120)
at demo.dao.repositories.PermissionRepositoryImplTest.testInsertPermissionBySP(PermissionRepositoryImplTest.java:118)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.type.SerializationException: could not serialize
at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:139)
at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:164)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.toBytes(SerializableTypeDescriptor.java:125)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.unwrap(SerializableTypeDescriptor.java:100)
at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.unwrap(SerializableTypeDescriptor.java:39)
at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:52)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:91)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:283)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:278)
at org.hibernate.loader.Loader.bindNamedParameters(Loader.java:1919)
at org.hibernate.loader.Loader.bindParameterValues(Loader.java:1845)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1716)
at org.hibernate.loader.Loader.doQuery(Loader.java:801)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2542)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
... 27 more
Caused by: java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
at org.hibernate.util.SerializationHelper.serialize(SerializationHelper.java:135)
... 48 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.