Hey all!
I am using Hibernate3 with DB2 v9.5 via IBMs DB2JCC driver, and I have run into a weird problem with mapping a view in my webapp. I have created a view that fetches some data from a table and mapped it as I would a table in the .hbm file. Strange behavior follows: when my application calls the get() method that should in theory return the Set of all objects returned from that view, Hibernate hangs somewhere. It does create the SQL command, and it eats up a connection as was proven by connections running out if I call the get() method too many times, but the connection seems to just hang on the Select indefinitely.
Previously, when using a table in place of the view, everything was working dandy. Switching to a view introduced this strange behavior. I am very new to Hibernate, so it's possible I am missing something obvious. All tables work great, but this one view does not play nice.
Below is a mock-up of what my mapping looks like. I reduced the number of columns being mapped and the names of entities, but the gist is there.
Code:
<class name="Foo" table="FooView" mutable="false">
<id name="id" column="FooId" type="long" access="field">
<generator class="native"></generator>
</id>
<property name="description" column="FooDescription" type="string" insert="false" update="false"/>
</class>
And here's what a view backing the above mapping would look like:
Code:
CREATE VIEW FooView
(FooId, FooDescription)
AS
(SELECT FooId, FooDescription from FooTable);