Hi

Basically I am making use of the new SQLServer time(7) type to store
time spans. (NOTE I know I can stick with the hbm for this one class
map but just thought I'd check if I'm missing something...)

In hbm I have this, which works well when I insert a new factor with
the use of the new NHIbernate type="TimeAsTimeSpan"

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-
import="true" namespace="MyApp.Model" assembly="MyApp.Model">
        <class table="race_videos" name="RaceVideo" lazy="false">
                <id name="Id" access="property" column="id">
                        <generator class="native"/>
                </id>
                <property name="FileName" access="property" column="filename" />
                <property name="Source" access="property" column="source" />
                <property name="GateOpenTime" access="property"
column="gate_open_time" type="TimeAsTimeSpan"/>
                <property name="WinnerFinishTime" access="property"
column="winner_finish_time" type="TimeAsTimeSpan" />
                </class>
</hibernate-mapping>

where-as I can't seem to specify the type attribute in Fluent. Custom
type isn't it as this TimeAsTimeSpan isn't an IUserType implementor.
Any ideas? SetAttribute would have been handy now I guess...

        public class RaceVideoFluentMap : ClassMap<RaceVideo>
        {
                public RaceVideoFluentMap()
                {
                        Table("race_videos");
                        Not.LazyLoad();
                        Id(x => x.Id)
                                .Column("id")
                                .GeneratedBy.Native();
                        Map(x => x.FileName)
                                .Column("filename")
                                .Access.Property();
                        Map(x => x.Source)
                                .Column("source")
                                .Access.Property();
                        Map(x => x.GateOpenTime)
                                .Column("gate_open_time")
                                .CustomType("TimeAsTimeSpanType")
                                .Access.Property();
                        Map(x => x.WinnerFinishTime)
                                .Column("winner_finish_time")
                                .CustomType("TimeAsTimeSpan")
                                .Access.Property();
                }
        }

with error below where you can see NHibernate is generating an insert
with a string the is a datetime rather than time...

INSERT INTO race_horse_factors (FactorName, time_in, time_out, weight,
other_excuse, user_id, race_horse_id) VALUES (@p0, @p1, @p2, @p3, @p4,
@p5, @p6); select SCOPE_IDENTITY();@p0 = 'UnderPressure', @p1 =
1/1/1753 12:00:00 AM, @p2 = 1/1/1753 12:00:03 AM, @p3 = 0, @p4 =
'UnderPressure', @p5 = 1, @p6 = 1
NHibernate: INSERT INTO race_horse_factors (FactorName, time_in,
time_out, weight, other_excuse, user_id, race_horse_id) VALUES (@p0,
@p1, @p2, @p3, @p4, @p5, @p6); select SCOPE_IDENTITY();@p0 =
'UnderPressure', @p1 = 1/1/1753 12:00:00 AM, @p2 = 1/1/1753 12:00:03
AM, @p3 = 0, @p4 = 'UnderPressure', @p5 = 1, @p6 = 1
2009-08-17 19:11:29,464 [Agent: adapter run thread for test
'CanAddFactor' with id 'da90bc10-c88e-4f0c-b7a1-6ba34f98f51b'] DEBUG
NHibernate.Transaction.AdoTransaction - Enlist Command
2009-08-17 19:11:29,663 [Agent: adapter run thread for test
'CanAddFactor' with id 'da90bc10-c88e-4f0c-b7a1-6ba34f98f51b'] ERROR
NHibernate.AdoNet.AbstractBatcher - Could not execute query: INSERT
INTO race_horse_factors (FactorName, time_in, time_out, weight,
other_excuse, user_id, race_horse_id) VALUES (@p0, @p1, @p2, @p3, @p4,
@p5, @p6); select SCOPE_IDENTITY()
System.Data.SqlClient.SqlException: String or binary data would be
truncated.
The statement has been terminated.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to