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.  [ 4 posts ] 
Author Message
 Post subject: "No row with the given identifier exists"? Hiberna
PostPosted: Tue Oct 30, 2007 11:19 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
Hi!

I've just started to explore NHibernate and got a problem wich I'm trying to solve for hours now... I want to create a very litte application which creates a db-entry and modifies the data afterwards:
Code:
            Configuration cfg = new Configuration();
            cfg.AddAssembly("HibernateSandbox");

            ISessionFactory factory = cfg.BuildSessionFactory();           
            ISession session = factory.OpenSession();
            ITransaction transaction = session.BeginTransaction();
           
            User newUser = new User();
            newUser.Id = "k3";
            newUser.UserName = "Topper";

            session.Save(newUser);

            transaction.Commit();
            session.Close();

            session = factory.OpenSession()
            [b]User joeCool = (User)session.Load(typeof(User), "k3");[/b]
            joeCool.UserName = "otherName";
            session.Flush();


The first parts works perfectly, bzt I'm not able to retrieve the values from the database. The "...session.load..." get's always a "No row with the given identifier exists" error. I as well tried to select data via the "session.CreateSQLQuery" but that didn't gave me any resukt either...

Thanks for any ideas what I'm doing wrong,

Martin[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 30, 2007 3:47 pm 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

How is your Id column defined in your database ? As a CHAR, VARCHAR,... ? Maybe the problem is that you defined the column as a CHAR(5) and so, you should be searching for 'k3 ' instead of 'k3' ? Just a thought...

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2007 4:58 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
Great! Thanks a lot, this has been the problem. Adding 18 blanks makes it work fine (got an ID of char(20)), but this can't be the best solution, can it?

Is there a way of avoiding this problem, eventually using somethins eles than char (on Oracle db)?

Thanks again, this gave me a good start in the day... ;)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2007 5:03 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

Glad I could help.
I think you can avoid this problem by defining your column as VARCHAR2 in Oracle.

_________________
Please rate this post if it helped.

X.


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

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.