Is there a way to get a reference to NHibernate Configuration at the runtime? I need it for SchemaExport().
Update: I am using StructureMap with FluentNHibernate to set it up, but I just want to know if I can get it from SessionFactory or some other object, after SessionFactory has been initialized, without having to rewrite setup in i...
How can I rewrite following so that I can do ObjectFactory.GetNamedInstance("MyNHConfiguration") at later time. "Configuration" is in the variable "cfg" under ExposeConfiguration lambda
ForRequestedType<ISessionFactory>()
.CacheBy(InstanceScope.Singleton)
.AddInstances(x => x.ConstructedBy(() =>
...
Why don't I have any class mappings after calling Configuration.Configure()?
Here is my class mapping file Category.hbm.xml for BudgetModel.Category:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="BudgetModel" namespace="BudgetModel">
<class name="Category" table="Categories">...
Hopefully, this fictitious example will illustrate my problem:
Suppose you are writing a system which tracks complaints for a software product, as well as many other attributes about the product. In this case the SoftwareProduct is our aggregate root and Complaints are entities that only can exist as a child of the product. In other w...
I am using the Table Per Subclass strategy to persist an inheritance heirarchy:
I am running into some confusion as to how to map the Debit class, which implements 2 interfaces. I may be overthinking it; I'm still learning NH.
Thanks for any input.
EDIT
What's confusing me is that the only properties that my concrete classes have, th...
Dear ladies and sirs.
Suppose I wish to inherit PersistentGenericBag, so that the actual type of my collection property is my custom type, which derives from PersistentGenericBag.
I see two possible ways to achieve this:
Introduce a new XML keyword, like mybag and somehow register my collection type with NHibernate to associated it w...
I have entities Post and Tag, where there is a many-to-many relationship between the two (e.g. each post can have one or more tags, and each tag can be associated with any number of posts).
What I would like to achieve is to have the Tag entity to have a field providing the number of posts which are associated with that tag. However, I ...
I've come up against a problem in converting my Fluent NH mapping to Sharp Architecture. I like the platform for it's ease, however it seems to handle entity mappings slightly differently to pure Fluent NH.
I have a Entity 'Category' that is a simple tree structure. I have to override the auto-mapping as there is a M:M property that I ...
I have schema, with such mapping.
Next code don't work:
IList<User> userList = session.CreateCriteria<User>()
.Add(Restrictions.Eq("Login", login))
.List<User>();
Exception:
System.InvalidCastException: Specified cast is not valid
Full stacktrace: link
...
Hi!
I have two problems.
1 . FNH does not test my component correcty and I dont know why.
System.ApplicationException: Expected
'DomainModel.Model.Publisher' but got
'DomainModel.Model.Publisher' for
Property 'Publisher'.
[TestMethod]
public void CanCorrectlyMapBook()
{
new PersistenceSpecification<Book>(_session)
...
I just started thinking about using the NHibernate second level cache in one of my apps. I would probably use the NHibernate.Caches.SysCache.SysCacheProvider which relies on ASP.net cache.
Enabling the cache was not a problem, but I am wondering on how to manage the cache e. g. programmatically removing certain entities from the cache e...
hai guys,
I am new to nhibernate please suggest some article to start knowing about nhibernate with asp.net mvc
...
I have the following nhibernate mapping
<class name="Customer">
<id name="Id">
<generator class="native"/>
</id>
<property name="Name"/>
<set name="Invoices" cascade="all" lazy="false">
<key column="CustomerId"/>
<one-to-many class="Invoice"/>
</set>
</class>
<class name="Invoice">
<id name="Id">
<generator ...
Hi all,
I'm struggling with getting Linq To NHibernate to work. I have referenced NHibernate, NHibernate.Linq and NHibernate.ByteCode.Castle . Also I have all other dependencies in the same folder.
Code / Error message:
Public Function GetProjectsByName(ByVal ProjectName As String) As List(Of Project)
Return (From x In _session....
I have a many to many relationship between A and B. (I know I can consider refactoring etc, but that's another matter).
my Code does something like this:
// given aId is the Id of an instance of A, and A has a many to many set of B's
A a = myActiveSession.Get<A>(aId);
a.Bs.Add(new B() {Name="dave"});
and I get an exception bec...
I have searched and have not found much documentation on the Subqueries.LeAll() method. Could someone show me a quick example of how it is used? Thanks!
...
I'm trying to specify the "select-before-update" attribute in a ClassMap using Fluent NHibernate, but I'm not finding much on the web that shows what the right way to do it is. Does anyone know how to achieve this with Fluent NHibernate? Thanks!
...
I am trying to register multiple NHibernate ISessions (multiple databases) by using the code below. I am getting "There is a component already registered for the given key Castle.MicroKernel.Registration.GenericFactory`1[[NHibernate.ISession, NHibernate, Version=2.1.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4]]" as the error...
i have a client server application, the server uses nhibernate.
i wanna know how should i use the session?
per call?
per client?
single?
other way?
and how can i keep the session cache in the server ?
and also i wanna know if the session is thread safe?
...
I am having a problem with a race condition when saving to the database asynchronously using NHibernate. First an insert to the database is done asynchronously where the unique id is auto-generated. Before this insert returns back to the main thread with now persisted object that has the unique database generated id, the object in upda...