Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# jmaynor 4/28/2005 2:09 PM
I buy into the benefits of using NHibernate. But I am having an impossible time getting even the most simple NHibernate tasks to complete sucessfully.

I created a demo app (Winform) called MusicTracker, based loosely on Hibernate : A Developer's Notebook application.

In it there is an Album class and an Track Class. I am attempting to make Album -> Track be a 1 -> Many relationship. I have the Album class implementing Tracks as an IList (arraylist internally). When I attempt to save an album:

Dim whosAfraid As New Album("Who's afraid of the Art of Noise?", #1/1/1997#)
Dim t1 As New Track("Peter Gunn", 123)
whosAfraid.Tracks.Add(t1)
t1 = New Track("Who's afraid?", 90)
whosAfraid.Tracks.Add(t1)
AlbumProvider.SaveAlbum(whosAfraid)

I get an ADO.Net error:

Message "Cannot insert the value NULL into column 'Album_ID', table 'MusicTracker.dbo.Track'; column does not allow nulls. INSERT fails.
The statement has been terminated." String

Can comeone take a look at the app and help me understand this simple mapping?

All of the source code and a bak file are available at: http://www.jamaynor.com/1/MusicTracker.zip

Thanks in advance.

Jeremy A Maynor

# bestcomy 4/29/2005 8:22 AM
set a default value for Album_ID

http://jira.nhibernate.org/confluence/display/NH/Quick+Start+Guide
use NHibernate
go

CREATE TABLE users (
LogonID nvarchar(20) NOT NULL default '0',
Name nvarchar(40) default NULL,
Password nvarchar(20) default NULL,
EmailAddress nvarchar(40) default NULL,
LastLogon datetime default NULL,
PRIMARY KEY (LogonID)
)
go
# jmaynor 5/2/2005 7:17 AM
Thank you bestcomy,

I have moved this thread to the NHibernate forums at : http://sourceforge.net/forum/forum.php?forum_id=252014

Thanks again,

Jeremy