Can you share some of your object model (C#) for this problem?

On Mon, Mar 30, 2009 at 9:46 AM, joshlrogers <[email protected]> wrote:
>
> I am even more confused now because when I set up a test case as per
> your link it works just fine.
>
> Thanks,
> Josh
>
> On Mar 30, 9:15 am, Fabio Maulo <[email protected]> wrote:
>> Do you can recreate the issue in a "stand-alone" NUnit test 
>> ?http://nhforge.org/blogs/nhibernate/archive/2008/10/04/the-best-way-t...
>>
>> 2009/3/30 joshlrogers <[email protected]>
>>
>>
>>
>> > Just thought I would give an update, I saw that there was a
>> > 2.1.0Alpha2 version so I upgraded and this issue is still there in
>> > this release.
>>
>> > Thanks,
>> > Josh
>>
>> > On Mar 30, 8:46 am, joshlrogers <[email protected]> wrote:
>> > > I apologize the version I am using is:
>>
>> > > NHibernate-2.0.1.GA-bin
>>
>> > > On Mar 30, 8:23 am, joshlrogers <[email protected]> wrote:
>>
>> > > > 1. It does the same thing when I switch to criteria:
>>
>> > > > public IList<CWTRatingGroup> GetAllCWTRatingGroups()
>> > > >         {
>> > > >             //return (List<CWTRatingGroup>)session.CreateQuery("select
>> > > > from TEAMS_ORM.CWTRatingGroup").List<CWTRatingGroup>();
>>
>> > > >             return session.CreateCriteria(typeof
>> > > > (CWTRatingGroup)).List<CWTRatingGroup>();
>> > > >         }
>>
>> > > > 2. I am using the most recent version I could download from
>> > > > hibernate.org
>>
>> > > >          2.0.0.Beta1
>>
>> > > > 3.  I'll keep that in mind, thank you....
>>
>> > > > Is there something I can do....I am thinking this is me because I am
>> > > > sure there have been others that needed to do the same thing and would
>> > > > have run into this issue.  I really have exhausted my resources as to
>> > > > what the cause could be.  I know my DB is right, I know that when I
>> > > > don't use NHibernate it works, and I seem to be out of options with
>> > > > NHibernate.  Anyone have any ideas?
>>
>> > > > Thank you,
>> > > > Josh
>>
>> > > > On Mar 27, 4:26 pm, Will Shaver <[email protected]> wrote:
>>
>> > > > > 1. Does it do this same thing if you do it via Criteria? >> Perhaps
>> > the
>> > > > > CreateQuery method of querying is broken?
>> > > > > 2. Are you using trunk or an old version?
>> > > > > 3. Unless you like extra typing you don't need to define Column="xx"
>> > if it
>> > > > > is identical to the Name field.
>>
>> > > > > On Fri, Mar 27, 2009 at 2:22 PM, joshlrogers <[email protected]>
>> > wrote:
>>
>> > > > > > 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-
>>
>> ...
>>
>> read more »
> >
>

--~--~---------~--~----~------------~-------~--~----~
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