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: SQLServer 2005 View
PostPosted: Wed Nov 21, 2007 1:36 pm 
Newbie

Joined: Wed Nov 21, 2007 1:27 pm
Posts: 4
NHibernate version: 1.2.0.GA
Database: SQLServer 2005 SP1

Hi everybody. I need to map an SQL View with NHibernate.
I just tried to map it like a table, but my view don't have any Identifier (just readonly data)... apparently NHibernate force my to define an identifier. Is there any way not to define an identifier or is the View mapping different as Table mapping ?

Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 21, 2007 7:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
As far as NHibernate is concerned, mapping to a table and a view are the same. You must define an identifier in the <class> mapping. If your view has a natural key, you can perhaps use <composite-id> to uniquely identify a row.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 4:18 am 
Newbie

Joined: Wed Nov 21, 2007 1:27 pm
Posts: 4
karlchu wrote:
As far as NHibernate is concerned, mapping to a table and a view are the same. You must define an identifier in the <class> mapping. If your view has a natural key, you can perhaps use <composite-id> to uniquely identify a row.


In fact I don't have a natural key and no column is unique. My view just represent readonly raw data.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 22, 2007 11:42 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
<composite-id> uses two or more columns to uniquely identify a row. If you don't have that, NHibernate cannot map to it. Next best thing you can do is to use a <sql-query>. Come to think of it, it is probably the right thing to recommend in the first place. Have a look and see if it suites your needs.

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 23, 2007 5:10 am 
Newbie

Joined: Wed Nov 21, 2007 1:27 pm
Posts: 4
karlchu wrote:
<composite-id> uses two or more columns to uniquely identify a row. If you don't have that, NHibernate cannot map to it. Next best thing you can do is to use a <sql-query>. Come to think of it, it is probably the right thing to recommend in the first place. Have a look and see if it suites your needs.


Thanks ! I think than sql-query is a good option because it's realy specifing need.


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.