lots of futzing with nhibernate to make it more efficient. I
don't think this works, but I don't want to loose the work before the weekend, and it doesn't break the build.0.6.0-stable
parent
0c84c27265
commit
17fd6cf661
|
@ -49,6 +49,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ISessionFactory factory;
|
private ISessionFactory factory;
|
||||||
|
private ISession session;
|
||||||
|
|
||||||
public override void Initialise()
|
public override void Initialise()
|
||||||
{
|
{
|
||||||
|
@ -87,17 +88,16 @@ namespace OpenSim.Data.NHibernate
|
||||||
cfg.AddInputStream(stream);
|
cfg.AddInputStream(stream);
|
||||||
|
|
||||||
factory = cfg.BuildSessionFactory();
|
factory = cfg.BuildSessionFactory();
|
||||||
|
session = factory.OpenSession();
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
|
Migration m = new Migration((System.Data.Common.DbConnection)factory.ConnectionProvider.GetConnection(), assem, dialect, "AssetStore");
|
||||||
m.Update();
|
m.Update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public AssetBase FetchAsset(LLUUID uuid)
|
override public AssetBase FetchAsset(LLUUID uuid)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -109,15 +109,12 @@ namespace OpenSim.Data.NHibernate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override public void CreateAsset(AssetBase asset)
|
override public void CreateAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
if (!ExistsAsset(asset.FullID))
|
if (!ExistsAsset(asset.FullID))
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
|
m_log.InfoFormat("[NHIBERNATE] inserting asset {0}", asset.FullID);
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
session.Save(asset);
|
session.Save(asset);
|
||||||
|
@ -125,13 +122,10 @@ namespace OpenSim.Data.NHibernate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override public void UpdateAsset(AssetBase asset)
|
override public void UpdateAsset(AssetBase asset)
|
||||||
{
|
{
|
||||||
if (ExistsAsset(asset.FullID))
|
if (ExistsAsset(asset.FullID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -140,7 +134,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void LogAssetLoad(AssetBase asset)
|
private void LogAssetLoad(AssetBase asset)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ISessionFactory factory;
|
private ISessionFactory factory;
|
||||||
|
private ISession session;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialises the interface
|
/// Initialises the interface
|
||||||
|
@ -76,6 +77,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||||
|
|
||||||
factory = cfg.BuildSessionFactory();
|
factory = cfg.BuildSessionFactory();
|
||||||
|
session = factory.OpenSession();
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
|
@ -98,8 +100,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// <param name="item">The UUID of the item to be returned</param>
|
/// <param name="item">The UUID of the item to be returned</param>
|
||||||
/// <returns>A class containing item information</returns>
|
/// <returns>A class containing item information</returns>
|
||||||
public InventoryItemBase getInventoryItem(LLUUID item)
|
public InventoryItemBase getInventoryItem(LLUUID item)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new inventory item based on item
|
/// Creates a new inventory item based on item
|
||||||
|
@ -120,8 +119,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
public void addInventoryItem(InventoryItemBase item)
|
public void addInventoryItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
if (!ExistsItem(item.ID))
|
if (!ExistsItem(item.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -129,7 +126,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID);
|
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists, updating instead", item.ID);
|
||||||
|
@ -144,8 +140,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
public void updateInventoryItem(InventoryItemBase item)
|
public void updateInventoryItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
if (ExistsItem(item.ID))
|
if (ExistsItem(item.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -153,7 +147,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID);
|
m_log.ErrorFormat("Attempted to add Inventory Item {0} that already exists", item.ID);
|
||||||
|
@ -165,8 +158,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item"></param>
|
/// <param name="item"></param>
|
||||||
public void deleteInventoryItem(LLUUID itemID)
|
public void deleteInventoryItem(LLUUID itemID)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -174,7 +165,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an inventory folder by its UUID
|
/// Returns an inventory folder by its UUID
|
||||||
|
@ -182,8 +172,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// <param name="folder">The UUID of the folder to be returned</param>
|
/// <param name="folder">The UUID of the folder to be returned</param>
|
||||||
/// <returns>A class containing folder information</returns>
|
/// <returns>A class containing folder information</returns>
|
||||||
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
public InventoryFolderBase getInventoryFolder(LLUUID folder)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -195,7 +183,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new inventory folder based on folder
|
/// Creates a new inventory folder based on folder
|
||||||
|
@ -204,8 +191,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
public void addInventoryFolder(InventoryFolderBase folder)
|
public void addInventoryFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
if (!ExistsFolder(folder.ID))
|
if (!ExistsFolder(folder.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -213,7 +198,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID);
|
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists, updating instead", folder.ID);
|
||||||
|
@ -228,8 +212,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
public void updateInventoryFolder(InventoryFolderBase folder)
|
public void updateInventoryFolder(InventoryFolderBase folder)
|
||||||
{
|
{
|
||||||
if (ExistsFolder(folder.ID))
|
if (ExistsFolder(folder.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -237,7 +219,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists", folder.ID);
|
m_log.ErrorFormat("Attempted to add Inventory Folder {0} that already exists", folder.ID);
|
||||||
|
@ -249,8 +230,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="folder"></param>
|
/// <param name="folder"></param>
|
||||||
public void deleteInventoryFolder(LLUUID folderID)
|
public void deleteInventoryFolder(LLUUID folderID)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
|
@ -258,7 +237,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// useful private methods
|
// useful private methods
|
||||||
private bool ExistsItem(LLUUID uuid)
|
private bool ExistsItem(LLUUID uuid)
|
||||||
|
@ -328,8 +306,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// <param name="folderID">The UUID of the target folder</param>
|
/// <param name="folderID">The UUID of the target folder</param>
|
||||||
/// <returns>A List of InventoryItemBase items</returns>
|
/// <returns>A List of InventoryItemBase items</returns>
|
||||||
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
public List<InventoryItemBase> getInventoryInFolder(LLUUID folderID)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
// try {
|
// try {
|
||||||
ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
|
ICriteria criteria = session.CreateCriteria(typeof(InventoryItemBase));
|
||||||
|
@ -346,7 +322,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
// return new List<InventoryItemBase>();
|
// return new List<InventoryItemBase>();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
public List<InventoryFolderBase> getUserRootFolders(LLUUID user)
|
||||||
{
|
{
|
||||||
|
@ -355,8 +330,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
|
|
||||||
// see InventoryItemBase.getUserRootFolder
|
// see InventoryItemBase.getUserRootFolder
|
||||||
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
public InventoryFolderBase getUserRootFolder(LLUUID user)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
|
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
|
||||||
criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
|
criteria.Add(Expression.Eq("ParentID", LLUUID.Zero));
|
||||||
|
@ -368,7 +341,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user);
|
m_log.ErrorFormat("No Inventory Root Folder Found for: {0}", user);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Append a list of all the child folders of a parent folder
|
/// Append a list of all the child folders of a parent folder
|
||||||
|
@ -377,9 +349,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
/// <param name="parentID">ID of parent</param>
|
/// <param name="parentID">ID of parent</param>
|
||||||
private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
|
private void getInventoryFolders(ref List<InventoryFolderBase> folders, LLUUID parentID)
|
||||||
{
|
{
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
|
|
||||||
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
|
ICriteria criteria = session.CreateCriteria(typeof(InventoryFolderBase));
|
||||||
criteria.Add(Expression.Eq("ParentID", parentID));
|
criteria.Add(Expression.Eq("ParentID", parentID));
|
||||||
foreach (InventoryFolderBase item in criteria.List())
|
foreach (InventoryFolderBase item in criteria.List())
|
||||||
|
@ -387,7 +356,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
folders.Add(item);
|
folders.Add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list of inventory folders contained in the folder 'parentID'
|
/// Returns a list of inventory folders contained in the folder 'parentID'
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ISessionFactory factory;
|
private ISessionFactory factory;
|
||||||
|
private ISession session;
|
||||||
|
|
||||||
public override void Initialise(string connect)
|
public override void Initialise(string connect)
|
||||||
{
|
{
|
||||||
|
@ -75,6 +76,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
cfg.AddAssembly("OpenSim.Data.NHibernate");
|
||||||
|
|
||||||
factory = cfg.BuildSessionFactory();
|
factory = cfg.BuildSessionFactory();
|
||||||
|
session = factory.OpenSession();
|
||||||
|
|
||||||
// This actually does the roll forward assembly stuff
|
// This actually does the roll forward assembly stuff
|
||||||
Assembly assem = GetType().Assembly;
|
Assembly assem = GetType().Assembly;
|
||||||
|
@ -86,12 +88,9 @@ namespace OpenSim.Data.NHibernate
|
||||||
{
|
{
|
||||||
UserProfileData user = null;
|
UserProfileData user = null;
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
|
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception) {}
|
catch (Exception) {}
|
||||||
|
|
||||||
return (user != null);
|
return (user != null);
|
||||||
|
@ -101,28 +100,20 @@ namespace OpenSim.Data.NHibernate
|
||||||
{
|
{
|
||||||
UserProfileData user;
|
UserProfileData user;
|
||||||
// TODO: I'm sure I'll have to do something silly here
|
// TODO: I'm sure I'll have to do something silly here
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
|
user = session.Load(typeof(UserProfileData), uuid) as UserProfileData;
|
||||||
user.CurrentAgent = GetAgentByUUID(uuid);
|
user.CurrentAgent = GetAgentByUUID(uuid);
|
||||||
}
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public void AddNewUserProfile(UserProfileData profile)
|
override public void AddNewUserProfile(UserProfileData profile)
|
||||||
{
|
{
|
||||||
if (!ExistsUser(profile.ID))
|
if (!ExistsUser(profile.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
|
||||||
{
|
{
|
||||||
session.Save(profile);
|
session.Save(profile);
|
||||||
SetAgentData(profile.ID, profile.CurrentAgent, session);
|
SetAgentData(profile.ID, profile.CurrentAgent);
|
||||||
// TODO: save agent
|
// TODO: save agent
|
||||||
transaction.Commit();
|
session.Transaction.Commit();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -131,7 +122,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SetAgentData(LLUUID uuid, UserAgentData agent, ISession session)
|
private void SetAgentData(LLUUID uuid, UserAgentData agent)
|
||||||
{
|
{
|
||||||
if (agent == null)
|
if (agent == null)
|
||||||
{
|
{
|
||||||
|
@ -140,32 +131,24 @@ namespace OpenSim.Data.NHibernate
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData;
|
UserAgentData old = session.Load(typeof(UserAgentData), uuid) as UserAgentData;
|
||||||
if (old == null)
|
if (old != null)
|
||||||
{
|
{
|
||||||
|
session.Delete(old);
|
||||||
|
}
|
||||||
|
|
||||||
session.Save(agent);
|
session.Save(agent);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
session.Update(agent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
override public bool UpdateUserProfile(UserProfileData profile)
|
override public bool UpdateUserProfile(UserProfileData profile)
|
||||||
{
|
{
|
||||||
if (ExistsUser(profile.ID))
|
if (ExistsUser(profile.ID))
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
|
||||||
{
|
{
|
||||||
session.Update(profile);
|
session.Update(profile);
|
||||||
SetAgentData(profile.ID, profile.CurrentAgent, session);
|
SetAgentData(profile.ID, profile.CurrentAgent);
|
||||||
transaction.Commit();
|
session.Transaction.Commit();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat("Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName);
|
m_log.ErrorFormat("Attempted to update User {0} {1} that doesn't exist, updating instead", profile.FirstName, profile.SurName);
|
||||||
|
@ -176,37 +159,28 @@ namespace OpenSim.Data.NHibernate
|
||||||
|
|
||||||
override public void AddNewUserAgent(UserAgentData agent)
|
override public void AddNewUserAgent(UserAgentData agent)
|
||||||
{
|
{
|
||||||
using (ISession session = factory.OpenSession())
|
UserAgentData old = session.Load(typeof(UserAgentData), agent.ProfileID) as UserAgentData;
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
if (old == null) {
|
||||||
{
|
|
||||||
session.Save(agent);
|
session.Save(agent);
|
||||||
transaction.Commit();
|
session.Transaction.Commit();
|
||||||
}
|
} else {
|
||||||
|
UpdateUserAgent(agent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateUserAgent(UserAgentData agent)
|
public void UpdateUserAgent(UserAgentData agent)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
|
||||||
{
|
{
|
||||||
session.Update(agent);
|
session.Update(agent);
|
||||||
transaction.Commit();
|
session.Transaction.Commit();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public UserAgentData GetAgentByUUID(LLUUID uuid)
|
override public UserAgentData GetAgentByUUID(LLUUID uuid)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
|
return session.Load(typeof(UserAgentData), uuid) as UserAgentData;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -214,8 +188,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
}
|
}
|
||||||
|
|
||||||
override public UserProfileData GetUserByName(string fname, string lname)
|
override public UserProfileData GetUserByName(string fname, string lname)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
|
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
|
||||||
criteria.Add(Expression.Eq("FirstName", fname));
|
criteria.Add(Expression.Eq("FirstName", fname));
|
||||||
|
@ -227,7 +199,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override public UserAgentData GetAgentByName(string fname, string lname)
|
override public UserAgentData GetAgentByName(string fname, string lname)
|
||||||
{
|
{
|
||||||
|
@ -246,8 +217,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
querysplit = query.Split(' ');
|
querysplit = query.Split(' ');
|
||||||
|
|
||||||
if (querysplit.Length == 2)
|
if (querysplit.Length == 2)
|
||||||
{
|
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
{
|
||||||
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
|
ICriteria criteria = session.CreateCriteria(typeof(UserProfileData));
|
||||||
criteria.Add(Expression.Like("FirstName", querysplit[0]));
|
criteria.Add(Expression.Like("FirstName", querysplit[0]));
|
||||||
|
@ -261,7 +230,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
results.Add(user);
|
results.Add(user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,20 +249,17 @@ namespace OpenSim.Data.NHibernate
|
||||||
{
|
{
|
||||||
AvatarAppearance appearance;
|
AvatarAppearance appearance;
|
||||||
// TODO: I'm sure I'll have to do something silly here
|
// TODO: I'm sure I'll have to do something silly here
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
|
appearance = session.Load(typeof(AvatarAppearance), user) as AvatarAppearance;
|
||||||
}
|
|
||||||
return appearance;
|
return appearance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ExistsAppearance(LLUUID uuid)
|
private bool ExistsAppearance(LLUUID uuid)
|
||||||
{
|
{
|
||||||
AvatarAppearance appearance;
|
AvatarAppearance appearance;
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance;
|
appearance = session.Load(typeof(AvatarAppearance), uuid) as AvatarAppearance;
|
||||||
}
|
|
||||||
return (appearance == null) ? false : true;
|
return (appearance == null) ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +267,7 @@ namespace OpenSim.Data.NHibernate
|
||||||
public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
|
public override void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
|
||||||
{
|
{
|
||||||
bool exists = ExistsAppearance(user);
|
bool exists = ExistsAppearance(user);
|
||||||
using (ISession session = factory.OpenSession())
|
|
||||||
{
|
|
||||||
using (ITransaction transaction = session.BeginTransaction())
|
using (ITransaction transaction = session.BeginTransaction())
|
||||||
{
|
{
|
||||||
if (exists)
|
if (exists)
|
||||||
|
@ -317,7 +281,6 @@ namespace OpenSim.Data.NHibernate
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override public void AddAttachment(LLUUID user, LLUUID item)
|
override public void AddAttachment(LLUUID user, LLUUID item)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
<property name="EveryOnePermissions" type="System.UInt32" />
|
<property name="EveryOnePermissions" type="System.UInt32" />
|
||||||
<property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
<property name="GroupID" index="item_group_id" type="OpenSim.Data.NHibernate.LLUUIDUserType, OpenSim.Data.NHibernate" />
|
||||||
<property name="GroupOwned" type="boolean" />
|
<property name="GroupOwned" type="boolean" />
|
||||||
<property name="SalePrice" type="Int32" />
|
<property name="SalePrice" type="System.Int32" />
|
||||||
<property name="SaleType" type="Int16" />
|
<property name="SaleType" type="System.Byte" />
|
||||||
<property name="Flags" type="Int32" />
|
<property name="Flags" type="Syste.UInt32" />
|
||||||
<property name="CreationDate" type="Int32" />
|
<property name="CreationDate" type="Int32" />
|
||||||
</class>
|
</class>
|
||||||
</hibernate-mapping>
|
</hibernate-mapping>
|
Loading…
Reference in New Issue