Reputation: 20916
I commit some data in DB with nhibernate.
TimeSlices newTimeSlices = new TimeSlices(timeSliceStartTime, timeSliceEndTime, schedule, newScheduleDay);
tsDao.Save(newTimeSlices);
tsDao.CommitChanges();
but then i try to read this data
public ScheduleDays GetByDate(DateTime date, Schedules schedule)
{
NHibernateSession.Refresh(schedule);
DateTime tmpDate = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
return NHibernateSession.CreateCriteria(typeof (ScheduleDays))
.Add(Restrictions.Eq(ScheduleDaysProperties.Date.ToString(), tmpDate))
.Add(Restrictions.Eq(ScheduleDaysProperties.Schedule.ToString(), schedule))
.UniqueResult<ScheduleDays>();
}
but without succeed. I look in DB and it is there but i can not read it from DB. How can i refresh session or what i must do that i can read this new data after i save it. Problem is only when i am working with ajax components.
public ScheduleDaysMap()
{
Id(x => x.ScheduleDayId);
Map(x => x.Date)
.Not.Nullable();
Map(x => x.MinutesOrderInterval)
.Not.Nullable();
References(x => x.Schedule)
.Column(TableNames.ScheduleId)
.Not.Nullable()
.LazyLoad();
HasMany(x => x.Orders)
.KeyColumn(TableNames.ScheduleDayId)
.Inverse()
.LazyLoad()
.AsBag();
HasMany(x => x.TimeSlices)
.KeyColumn(TableNames.ScheduleDayId)
.Inverse()
.LazyLoad()
.AsBag();
Version(x => x.Timestamp);
}
timeSliceStartTime, timeSliceEndTime and newTimeSlices are type od DateTime
schedule is DB object type (Table Schedules)
newScheduleDay is DB object type (Table ScheduleDays)
I am using C# + fluent nhibernate 1.1
Can be problem with mapping and lazy load or asbag? Or what can be wrong?
Upvotes: 1
Views: 837
Reputation: 15579
Hey Can you run nhibernate profiler and see what query is getting fired. The link to the same is nhprof.com
Google to see how to use nhprof its very simple. Hope that helps
Upvotes: 0
Reputation: 11244
I don't know the problem, but here is how I would debug it:
nHibernate does not cache queries unless you tell it to.
Upvotes: 1