-->
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 and database view
PostPosted: Thu Apr 02, 2009 10:13 am 
Newbie

Joined: Thu Apr 02, 2009 10:09 am
Posts: 3
Hi,

I have to use database views with Hibernate.
Do you have a working example or some recommendation
on how to create an entity to work with views.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 3:45 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Hibernate doesn't even need to know that it is using a view

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 3:50 pm 
Newbie

Joined: Thu Apr 02, 2009 10:09 am
Posts: 3
I suppose it should not.

Did you actually try this.
Please send me a working example.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 4:03 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Just put the view name instead of the table name. We use views often.

Code:
<class
    name="foo.Apple"
    table="view_apple"
>


I'm not going to condone using inserts against a view that is a join of two tables though. I've never done it, but it seems unnecessarily complex.

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 02, 2009 4:57 pm 
Newbie

Joined: Thu Apr 02, 2009 10:09 am
Posts: 3
Sorry,
i was not precise,

I use Entity manager and JPA annotations.
Do you have an example with JPA annotations ?

Thanks.


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.