-->
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.  [ 8 posts ] 
Author Message
 Post subject: mappingfiles: <id><generator> always necessary?
PostPosted: Sun Jan 13, 2008 4:10 pm 
Newbie

Joined: Sun Jan 13, 2008 6:48 am
Posts: 16
hi,

it's me again:
while solving my other problem, i came accross the question if it's always necessary to have an id-section for PK in the mapping files?

let's say, i have a SQL-view which is just used for reading and i'm not interested in having a primary key, how can i achieve this?

thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 13, 2008 5:59 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
In your case, the id would be "assigned", without generator.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 13, 2008 7:05 pm 
Newbie

Joined: Sun Jan 13, 2008 6:48 am
Posts: 16
hi,
thank you for your input.

what i mean is, are there any chance of getting rid of the <id>-block within the mapping files?
in my case, i don't need the <id>-block since i'm just looking up some information in that view - but having the <id>-block enforces me to load also the PK/ID column within the view and i'm trying to avoid this.

(i tried also "mapping" the <id>-block onto an existing column which is loaded within the view, but this causes bugs.)

the problem is: if i throw out the <id>-block, the application won't run...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 1:31 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
as far as I know, you have to always specify the id.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 14, 2008 5:01 pm 
Newbie

Joined: Sun Jan 13, 2008 6:48 am
Posts: 16
hi,

thanks for your reply.

ok, if i can't get rid off it ... then i can't get rid off it.

perhaps someone from the NHibernate team can confirm this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 1:32 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
i'm afraid there is no way to eliminate the id as it acts as an object identifier. We declare an artificial primary key on each view by adding a guid value via

Code:
newid() as ID


to each view definition.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 18, 2008 4:35 am 
Newbie

Joined: Sun Jan 13, 2008 6:48 am
Posts: 16
Luedi,

is it possible to map the <id> tag on a distinct coloumn which is included in the views output or may this interfere with the result of the view (and its validity) ?

the reason is simple:
in my case, i don't need a PK in the result of my view, so i need to map the <id>-tag to another column, if the <id>-tag is necessary...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 19, 2008 12:06 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
definetly yes. But you must ensure that the column values are unique.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.