-->
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: Need help with mapping
PostPosted: Wed Jul 14, 2010 2:56 pm 
Newbie

Joined: Wed Jul 14, 2010 2:48 pm
Posts: 1
I am re-writing an app that sits over a legacy database. I'm using NHibernate and I've had problems getting some mappings to work and would like some help.

First, the table structure:

Tech:
Id
FirstName
LastName

User:
TechID
Username


The "User" table has no primary key. Foreign keys are no enforced at all. TechId is support to correspond to the Id on the Tech table.

My classes in memory are:

Tech:
Id
FirstName
LastName
User (type: User)

User:
Id
Username

The tables and objects will always be 1-1.

At first I tried a HasOne relationship in the mappings but everytime it tried to save it did an update instead of an insert and when creating a new record I would get the infamous "update count expect: 1, actual:0 " type message.

I am also fine with changing my model so the Username is directly on the Tech but I can't get that mapping to work either.

Any suggestions are greatly appreciated.

Thanks


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.