Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Examples/ForumQuestions/T1104613
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23374/ForumQuestions/T1104613
Added Files:
A.cs A.hbm.xml AOuterJoin.cs OuterJoinFixture.cs
Log Message:
Adding examples into cvs.
--- NEW FILE: A.cs ---
using System;
using System.Collections;
namespace NHibernate.Examples.ForumQuestions.T1104613
{
/// <summary>
/// Summary description for A.
/// </summary>
public class A
{
private string _key;
private string _name;
private AManyToOne _manyToOne;
private IList _outerJoins;
public string Key
{
get { return _key; }
set { _key = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
public AManyToOne ManyToOne
{
get { return _manyToOne; }
set { _manyToOne = value; }
}
public IList OuterJoins
{
get { return _outerJoins; }
set { _outerJoins = value; }
}
}
}
--- NEW FILE: AOuterJoin.cs ---
using System;
namespace NHibernate.Examples.ForumQuestions.T1104613
{
/// <summary>
/// Summary description for AOuterJoin.
/// </summary>
public class AOuterJoin
{
private string _key;
private string _name;
public string Key
{
get { return _key; }
set { _key = value; }
}
public string Name
{
get { return _name; }
set { _name = value; }
}
}
public class AManyToOne : AOuterJoin
{
}
}
--- NEW FILE: A.hbm.xml ---
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="NHibernate.Examples.ForumQuestions.T1104613.A, NHibernate.Examples" table="a">
<id name="Key" column="a_id" type="String">
<generator class="uuid.hex" />
</id>
<property name="Name" />
<many-to-one name="ManyToOne" not-null="true" outer-join="true" />
<list name="OuterJoins" table="a_oj_list">
<key column="a_id" />
<index column="a_oj_index" />
<many-to-many
class="NHibernate.Examples.ForumQuestions.T1104613.AOuterJoin, NHibernate.Examples"
outer-join="true"
/>
</list>
</class>
<class name="NHibernate.Examples.ForumQuestions.T1104613.AOuterJoin, NHibernate.Examples" table="a_oj">
<id column="a_oj_id" name="Key">
<generator class="uuid.hex" />
</id>
<property name="Name" unique="true" not-null="true" length="50" />
</class>
<class name="NHibernate.Examples.ForumQuestions.T1104613.AManyToOne, NHibernate.Examples" table="a_mto">
<id column="a_mto_id" name="Key">
<generator class="uuid.hex" />
</id>
<property name="Name" unique="true" not-null="true" length="50" />
</class>
</hibernate-mapping>
--- NEW FILE: OuterJoinFixture.cs ---
using System;
using System.Collections;
using NHibernate;
using NUnit.Framework;
namespace NHibernate.Examples.ForumQuestions.T1104613
{
/// <summary>
/// Testing outer-join loading with simple classes. I'm not sure how to
/// write a Unit Test to see if this is working or not other than just
/// look at the sql profilers output.
/// </summary>
[TestFixture]
public class OuterJoinFixture : TestCase
{
[SetUp]
public void SetUp()
{
ExportSchema( new string[] { "T1104613.A.hbm.xml"}, true );
}
[Test]
public void LoadWithOuterJoin()
{
ISession s = sessions.OpenSession();
const int numOfOjs = 5;
A theA = new A();
AManyToOne mto = new AManyToOne();
IList ojList = new ArrayList(numOfOjs);
theA.Name = "the A";
mto.Name = "many-to-one";
theA.ManyToOne = mto;
for( int i=0; i<numOfOjs; i++)
{
AOuterJoin aoj = new AOuterJoin();
aoj.Name = "the oj list " + i;
ojList.Insert(i, aoj);
}
theA.OuterJoins = ojList;
for( int i=0; i<numOfOjs; i++)
{
s.Save(ojList[i]);
}
s.Save(mto);
s.Save(theA);
s.Flush();
s.Close();
s = sessions.OpenSession();
theA = (A)s.Load( typeof(A), theA.Key );
s.Close();
}
}
}
|