I have actually changed it to not have a type and I am still receiving
the same result....

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
assembly="TEAMS_ORM" schema="dbo">
        <class name ="TEAMS_ORM.CWTRatingGroup,TEAMS_ORM"
table="tblCWTRatingGroups">

                <id name="Id" column="Id" type="Int32" unsaved-value="-1">
                        <generator class="native" />
                </id>

                <property name="Name" column="Name" length="50" type="String" 
not-
null="true" unique="true" insert="true" update="true" />
                <property name="UserAdded" column="UserAdded" type="Int32" not-
null="true" insert="true" update="false"/>
                <property name="DateAdded" column="DateAdded" type="DateTime" 
not-
null="true" insert="true" update="false" />
                <property name="UserEdited" column="UserEdited" not-null="false"
insert="false" update="true" />
                <property name="DateEdited" column="DateEdited" not-null="false"
insert="false" update="true" />

                <bag name="RatingRules" table="tblCWTRatingGroups_RatingRules"
cascade="all">
                        <key column="GroupId" />
                        <many-to-many column = "RuleId" 
class="TEAMS_ORM.CWTRatingRule,
TEAMS_ORM" />
                </bag>

        </class>

</hibernate-mapping>

This still gives me a 1 for UserEdited and the current date for
DateEdited.  However if I do a SELECT query from the DB those values
are null and if I do a dataset and do the query myself they are null.
The issue is definitely a NHibernate issue I think it is safe to say
at this point.

Thanks,
Josh

On Mar 27, 4:15 pm, epitka <[email protected]> wrote:
> I know, that's why I said I am not sure, either doc is not correct or
> joshlrogers is doing something wrong.
>
> On Mar 27, 4:12 pm, Will Shaver <[email protected]> wrote:
>
> > Well before you change it someone should do a test. I never actually put
> > types in my mapping unless I'm implementing IUserType, so I'm not sure on
> > this one.
>
> > On Fri, Mar 27, 2009 at 2:12 PM, epitka <[email protected]> wrote:
>
> > > Then this needs to be changed in the documentation:
>
> > > "NHibernate supports .NET 2.0 Nullable types. These types are mostly
> > > treated the same as plain non-Nullable types internally. For example,
> > > a property of type Nullable<Int32> can be mapped using type="Int32" or
> > > type="System.Int32".
>
> > > If you do not specify a type, NHibernate will use reflection upon the
> > > named property to take a guess at the correct NHibernate type.
> > > NHibernate will try to interpret the name of the return class of the
> > > property getter using rules 2, 3, 4 in that order. However, this is
> > > not always enough. In certain cases you will still need the type
> > > attribute. (For example, to distinguish between
> > > NHibernateUtil.DateTime and NHibernateUtil.Timestamp, or to specify a
> > > custom type.)"
>
> > > On Mar 27, 4:03 pm, Will Shaver <[email protected]> wrote:
> > > > Ack, of course epitka is right. Remember that nullable types are 
> > > > actually
> > > > implemented with the backtick operator.
> > > > Remember that this:
> > > > ?int
> > > > is actually this:
> > > > System.Nullable``1[[System.Int32]]
>
> > > > or something like that...
>
> > > >  -Will
>
> > > > On Fri, Mar 27, 2009 at 2:00 PM, epitka <[email protected]> wrote:
>
> > > > > I am not sure about this, but try taking "type" attribute out of your
> > > > > mapping and let NH figure out what the type is.
>
> > > > > On Mar 27, 1:43 pm, joshlrogers <[email protected]> wrote:
> > > > > > Yes this is definite.  I run a query through a plain old data set 
> > > > > > and
> > > > > > they return null.  I have verified my database design as 
> > > > > > well....just
> > > > > > for clarification sake:
>
> > > > > > CREATE TABLE [dbo].[tblCWTRatingGroups](
> > > > > >         [Id] [int] IDENTITY(0,1) NOT NULL,
> > > > > >         [Name] [nvarchar](50) NOT NULL,
> > > > > >         [UserAdded] [int] NOT NULL,
> > > > > >         [DateAdded] [datetime] NOT NULL,
> > > > > >         [UserEdited] [int] NULL,
> > > > > >         [DateEdited] [datetime] NULL,
> > > > > >  CONSTRAINT [PK_tblCWTRatingGroups] PRIMARY KEY CLUSTERED
> > > > > > (
> > > > > >         [Id] ASC
> > > > > > )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF,
> > > IGNORE_DUP_KEY
> > > > > > = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON, FILLFACTOR =
> > > 20)
> > > > > > ON [PRIMARY]
> > > > > > ) ON [PRIMARY]
>
> > > > > > That was taken straight from SQL Server Management Studio....
>
> > > > > > Thank you,
> > > > > > Josh
>
> > > > > > On Mar 27, 1:29 pm, James Gregory <[email protected]> wrote:
>
> > > > > > > Just to confirm, your columns in your database definitely are
> > > nullable?
>
> > > > > > > On Fri, Mar 27, 2009 at 5:59 PM, joshlrogers <
> > > [email protected]>
> > > > > wrote:
>
> > > > > > > > Hello,
>
> > > > > > > > I am having an issue with nullable fields.  I have specified the
> > > > > > > > valuetypes as being nullable, respectively DateTime? and int?.
> > >  The
> > > > > > > > constructor of the class sets these values to null as well.  My
> > > > > > > > mapping is as such:
>
> > > > > > > > <?xml version="1.0" encoding="utf-8" ?>
> > > > > > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> > > > > > > > assembly="TEAMS_ORM">
> > > > > > > >        <class name ="TEAMS_ORM.CWTRatingGroup,TEAMS_ORM"
> > > > > > > > table="tblCWTRatingGroups">
>
> > > > > > > >                <id name="Id" column="Id" type="Int32"
> > > > > unsaved-value="-1">
> > > > > > > >                        <generator class="native" />
> > > > > > > >        </id>
>
> > > > > > > >                <property name="Name" column="Name" length="50"
> > > > > > > > type="String" not-
> > > > > > > > null="true" unique="true" />
> > > > > > > >                <property name="UserAdded" column="UserAdded"
> > > > > type="Int32"
> > > > > > > > not-
> > > > > > > > null="true" />
> > > > > > > >                <property name="DateAdded" column="DateAdded"
> > > > > > > > type="DateTime" not-
> > > > > > > > null="true" />
> > > > > > > >                <property name="UserEdited" column="UserEdited"
> > > > > type="Int32"
> > > > > > > > not-
> > > > > > > > null="false" />
> > > > > > > >                <property name="DateEdited" column="DateEdited"
> > > > > > > > type="DateTime" not-
> > > > > > > > null="false" />
>
> > > > > > > >        </class>
>
> > > > > > > > </hibernate-mapping>
>
> > > > > > > > UserEdited and DateEdited are the required fields.  When I make
> > > > > > > > updates or saves to the db it will successfully pass nulls.
> > >  However
> > > > > > > > when it retrieves from the DB and the fields are NULL it
> > > populates
> > > > > the
> > > > > > > > fields with arbitrary values however I need them to be null.
> > >  This is
> > > > > > > > my retrieve query:
>
> > > > > > > > return (List<CWTRatingGroup>)session.CreateQuery("select from
> > > > > > > > TEAMS_ORM.CWTRatingGroup").List<CWTRatingGroup>();
>
> > > > > > > > How do I achieve this?
>
> > > > > > > > Thank you in advance,
> > > > > > > > Josh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to