-->
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.  [ 1 post ] 
Author Message
 Post subject: Oracle Oject Type java.sql.STRUCT with stored procedure
PostPosted: Tue Dec 19, 2006 11:22 am 
Newbie

Joined: Tue Dec 19, 2006 11:07 am
Posts: 1
Hi,
I am trying to pass an Oracle Type object to a stored procedure. It works fine when i use plain JDBC, but using hibernate has become a challenge. Can anyone please guide me towards the right direction.

UserTypeType implements UserType

Here is what i am trying to do:

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
java.sql.Connection conn = session.connection();
PreparedStatement ps = conn.prepareStatement("call user_pkg.ADD_NEW_USER(?,?)"); // dont know if creating this is right, it was done because nullSafeSet() requires a preparedStatement .

User user = new User();
user.setUserName("user6");
user.setFirstName("fname2");
user.setLastName("lname2");
user.setEmail("email2");
user.setPassword("password");
user.setAccessRoleId(new Integer(4));
user.setAssignedRoleId(new Integer(5));
user.setActive("Y");

UserTypeType type = new UserTypeType();
type.nullSafeSet(ps, user, 1);
Query qry = (Query)session.getNamedQuery("addNewUser");
qry.setParameter(1, type, Hibernate.custom(UserTypeType.class));
Object obj = qry.uniqueResult();

xml mapping
<sql-query name="addNewUser" callable="true">
{ call user_pkg.ADD_NEW_USER(?,?) }
</sql-query>


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

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.