Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: LAST
Mapping documents:
using System;
using System.Collections.Generic;
using System.Text;
namespace Core.Entidade
{
public class Turma
{
private Int64 _id;
private string _nome;
private short _particular;
private IList<Aluno> _alunos;
public Turma()
{
}
public virtual Int64 id
{
get { return _id; }
set { _id = value; }
}
public virtual string nome
{
get { return _nome; }
set { _nome = value; }
}
public virtual short particular
{
get { return _particular; }
set { _particular = value; }
}
public virtual IList<Aluno> alunos
{
get { return _alunos; }
set { _alunos = value; }
}
}
}
Code between sessionFactory.openSession() and session.close():
ISessionFactory factory = config.BuildSessionFactory();
ISession session = factory.OpenSession();
Aluno aluno = (Aluno) session.Load(typeof(Aluno), Convert.ToInt64(5));
Turma turma = new Turma();
turma.nome = "Teste";
turma.particular = 0;
turma.alunos.Add(aluno);
session.Save(turma);
session.Close();
Full stack trace of any exception that occurs:
[NullReferenceException: Object reference not set to an instance of an object.]
_Default.Page_Load(Object sender, EventArgs e) in c:\Projetos\EnglishService\Default.aspx.cs:35
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3035
Name and version of the database you are using: SQL Server 2000
[b]The generated SQL (show_sql=true):[ Yes/b]
When i try to acess any method or variable in turma.aluno, the debug give me this error.