-->
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.  [ 1 post ] 
Author Message
 Post subject: Detached Entity Issue
PostPosted: Tue Jan 27, 2009 7:53 am 
Newbie

Joined: Tue Jan 27, 2009 7:28 am
Posts: 1
Hibernate version: 2.0.0.2002

Sorry if this seems a bit messed but im doing this at speed!

Ok guys, i am sure there is a pretty simple explanation for this one and i am sure other people may have worked this out on their own but i am racking my brains about this one and i kinda have to have this solved by the end of the day........well a few hours.

Everything in NHibernate we have done works perfectly, no problems what so ever. However this is what we are trying to do:

We read some values from another database. For each of these values we need to determine if in one of it's related tables, the values exist...eg:

Read value:

User Entity:

UserID: 0 (new value)
Username: test
Application Entity: (Contains AppID, AppName)

We need to either add a new 'Application' or get an existing one. Generating a new one is not a problem. But this is what we do:

For each record, if the application already exists, we need to fill an Application Entity with this existing application from the database, if not create a new one. So we find that an application specified in our search already exists in the database. So we return for instance:

Application Entity:

AppID: 1
AppName: TestApp

We attach this application entity to our user entity, resulting in thus:

User Entity:

UserID: 0 (new value)
Username: test
Application Entity: (AppID: 1, AppName: TestApp)

Now when it comes to the persist, it fails giving us the following error 'Detached Entity passed to persist'.

So is what i am doing just a misunderstanding of NHibernate? Please bear in mind that i have been given 3 days to learn this, the business objects and code on an existing application so i may have missed a step somewhere.

Any help would be greatly appreciated.


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

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.