-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping view as a table in hbm, Hibernate times out
PostPosted: Thu Sep 13, 2012 7:46 pm 
Newbie

Joined: Thu Sep 13, 2012 7:35 pm
Posts: 3
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);


Last edited by brainsoup on Mon Sep 17, 2012 3:22 pm, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: Mapping view as a table in hbm, Hibernate times out
PostPosted: Sat Sep 15, 2012 12:11 am 
Beginner
Beginner

Joined: Fri Sep 14, 2012 10:41 am
Posts: 20
You are not describing your problem in sufficient details. What is a view? If you are new to Hibernate, there are many mistakes you can make to make it hang. Even the simple example you posted has a mistake: your description string does not have a length="" attribute. Could it be that the string exceeds that length? Could that be possible in some other string somewhere?

If I were, you I would edit my problem description to be more detailed so people can get a grasp of your environment. I suspect that your problem might be in your class metadata file (*.hbm.xml) files but I can't be sure.


Top
 Profile  
 
 Post subject: Re: Mapping view as a table in hbm, Hibernate times out
PostPosted: Mon Sep 17, 2012 3:19 pm 
Newbie

Joined: Thu Sep 13, 2012 7:35 pm
Posts: 3
Hey! Thank you for the reply. To clarify, I am running IBM DB2 v9.5 and am using a View to select some fields from a table. I need a view for a somewhat complex query, but for this test I replaced it with a simple select ala:
Code:
CREATE VIEW FooView
(FooId, FooDescription)
AS
(SELECT FooId, FooDescription from FooTable);


I have edited my OP to reflect this information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.