-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate, DB2 and views - Is this possible
PostPosted: Tue Dec 23, 2003 10:25 am 
Newbie

Joined: Tue Dec 23, 2003 10:21 am
Posts: 2
Hi,

Before I delve into the inards of Hibernate and its documentation, I thought I just as well post the question on the forum.

Is it possible to have Hibernate use DB2 views instead of the actual tables?

Thanks in advance,

Iwan Eising


Top
 Profile  
 
 Post subject: Re: Hibernate, DB2 and views - Is this possible
PostPosted: Tue Dec 23, 2003 11:27 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
E-One wrote:
Before I delve into the inards of Hibernate and its documentation, I thought I just as well post the question on the forum.

Before posting to the forum, how about searching the forum.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2003 11:40 am 
Beginner
Beginner

Joined: Fri Oct 10, 2003 4:54 pm
Posts: 26
Location: Chicago, IL
But to answer your question, yes it is possible, although you may need to define surrogate keys because Hibernate requires you to define a set of columns that make each row in the view unique (worst case, this would be every column in the view).


Top
 Profile  
 
 Post subject: Hibernate, DB2 and views - Is this possible
PostPosted: Wed Dec 24, 2003 4:02 am 
Newbie

Joined: Tue Dec 23, 2003 10:21 am
Posts: 2
loverde wrote:
But to answer your question, yes it is possible, although you may need to define surrogate keys because Hibernate requires you to define a set of columns that make each row in the view unique (worst case, this would be every column in the view).


Could you explain how this differs from using tables directly? I use native ID generation for PK's.
What I am doing is developing locally using MySQL and tables and I need to use DB2 and views as this is the standard for our company. Since recently we're bound to use Hibernate and I like it a lot, although there's quite some documentation that I find either hard to find or not to be found at all.

Thanks in advance,
Iwan


Top
 Profile  
 
 Post subject: Re: Hibernate, DB2 and views - Is this possible
PostPosted: Wed Dec 24, 2003 8:44 pm 
Beginner
Beginner

Joined: Fri Oct 10, 2003 4:54 pm
Posts: 26
Location: Chicago, IL
E-One wrote:
Could you explain how this differs from using tables directly? I use native ID generation for PK's.
What I am doing is developing locally using MySQL and tables and I need to use DB2 and views as this is the standard for our company. Since recently we're bound to use Hibernate and I like it a lot, although there's quite some documentation that I find either hard to find or not to be found at all.


Well, doing inserts into views is generally a dangerous practice, but that aside...

Assuming that the views are pretty much one to one mappings to actual tables, you can feel free to use Hibernate as if the views were tables.

However, where things get murky is when you are using views to combine data from multiple tables into some result set. Usually (hopefully), these types of views are intended for read-only, so you shouldn't have to worry about id generation for them. However, as I stated before, Hibernate still requires you to define some set of columns within the view that will be unique (even if *you* don't care about the uniqueness). So in the extreme case, you might have to map all of the columns of the view as a composite key as far as Hibernate is concerned.[/list]


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