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!
|