-->
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 UserTypes
PostPosted: Thu Jul 10, 2008 7:15 pm 
Newbie

Joined: Thu Jul 10, 2008 6:58 pm
Posts: 1
My issue has been solved but I would like to know if there is another (easier) way I could have handled it.

There is an oracle table, mytable, that has several fields, varchar2 and integers. It also has a usertype field that contains an object, myobj. Myobj contains 4 fields of various types. I was able to successfully read this table. So far, no problem.

On table inserts, all fields in the row are populated except: myobj should only be passed 2 fields. The other 2 fields are computed in an overridden constructor. Passing null values for the missing fields is not correct because the constructor is looking for only 2 values.

I tried several approaches to this but the one that finally worked was:
I create 2 classes for this table, one is the same one that I read with. The other one was the same except I removed the myobj property and replaced it with the two fields needed to populate the object.

I also had 2 .hbm files. In the 2nd file, I created a <sql-insert> with the proper sql needed to insert records.

Now, when an insert is needed, I use one object. For updates, deletes, and queries, I use another.

I feel like this is somewhat confusing but I could not figure out what else to do. Can you?

Oracle 9.2
Websphere 6.?
Hibernate 3.2

Thanks for taking the time to read this.

ps: i didn't create the table, i just have to use it!


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.