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.  [ 1 post ] 
Author Message
 Post subject: Formula Datepart Mapping
PostPosted: Thu May 13, 2010 7:58 am 
Newbie

Joined: Thu May 13, 2010 7:55 am
Posts: 2
Hi There,

i have a very simple table with a Datetime column and i have this mapping in my domain object.

MyDate is the name of the datetime column in the DB.

Code:
public virtual int Day { get; set; }
public virtual int Month { get; set; }
public virtual int Year { get; set; }
public virtual int Hour { get; set; }
public virtual int Minutes { get; set; }
public virtual int Seconds { get;set; }
public virtual int WeekNo { get; set; }


Code:
Map(x => x.Day).Formula("DATEPART(day, Datetime)");
Map(x => x.Month).Formula("DATEPART(month, Datetime)");
Map(x => x.Year).Formula("DATEPART(year, Datetime)");
Map(x => x.Hour).Formula("DATEPART(hour, Datetime)");
Map(x => x.Minutes).Formula("DATEPART(minute, Datetime)");
Map(x => x.Seconds).Formula("DATEPART(second, Datetime)");
Map(x => x.WeekNo).Formula("DATEPART(week, Datetime)");


This is working all great .... but Week Datepart.

I saw with NHProf the sql generating for a select and here's the problem it's generating all the sql correctly but for week datepart.. this is part of the SQL generated:

....Datepart(day, MyDate) ... ....Datepart(month, MyDate) ... ....Datepart(year, MyDate) ... ....Datepart(hour, MyDate) ... ....Datepart(minute, MyDate) ... ....Datepart(second, MyDate) ... ....Datepart(this_.week, MyDate) ...

where this_ is the alias for the table that nhibernate uses.

so it's treating the week keyword for the datepart stuff as a column or something like that. To clarify there's no column or properties that is called week.

some help ?

cheers

Alessandro


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.