-->
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: could not insert a single record
PostPosted: Wed Sep 09, 2009 2:26 am 
Beginner
Beginner

Joined: Sat Aug 01, 2009 6:44 am
Posts: 24
Hi,

I made a small application in Nhibernate..

my table is:
CREATE TABLE [dbo].[UserInterests](
[Id] [int] IDENTITY(1,1) NOT NULL,
[UserId] [int] ,
[InterestID] [int]
) ON [PRIMARY]
and FYI this is junction table

This is my class


public class UserInterests
{
private int _Id;
private int _userid;
private IList<UserInterests> _UserInterestsList;
private IList<UserInterests> _UserInterestsList2;
private int _interestid;
}


This is my Mapping File

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="DTO" namespace="Business.Entities">

<class name="Business.Entities.UserInterests" table="UserInterests" >

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


<!-- composite primary key support is touchy. View the documentation for syntax. -->

<bag name="UserInterestsList" inverse="true" lazy="true" cascade="all">
<key column="UserId" />
<one-to-many class="UserInterests" />

</bag>

<bag name="UserInterestsList2" inverse="true" lazy="true" cascade="all" >
<key column="InterestID" />
<one-to-many class="UserInterests" />

</bag>

</class>
</hibernate-mapping>





and i am unable to save session with proper values
public void addUserInterest(UserInterests userInterest)
{
try
{
session.Save(userInterest);
session.Flush();
}
catch (Exception ex)
{
throw ex;
}
}



but unfortunately Sesseion.save() didn't save data into the table... even though while debugging UserInterest contains all the data but after execution... i cant find data in the table.
and got
1 Null Null
2 Null Null
3 Null Null
4 Null Null
5 Null Null

just identity is working and rest of records didnt get there .... Dont know why; Can some body ans me?


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.