I'm importing data that may or may not exist already in my database. I'd like NHibernate to associate any entities with the existing db one if it exists (probably just setting the primary key/id), or create a new one if it doesn't. I'm using S#arp architecture for my framework (MVC 2, NHibernate, Fluent).
I've added the [HasUniqueDoma...
I am using NHibernate 2.0.1 and IPreUpdateEventListener,IPreInsertEventListener events for audit logging purposes.
I have a basic entity that has a one to many relation like this.
User------->Books
From an ASP.NET MVC controller method i am adding a book to a user like this.
Book book =new Book("LOTR");
var userBook=user.AddBook(boo...
Hi
I am doing some work on an application that uses an existing schema that cannot be altered. Whilst writing my NHibernate mappings I encountered a strange many-to-many relationship. The relationship is defined in the standard way as in this question with the addition of a boolean flag on the association table that signifies if the rel...
I'm having some trouble constructing the correct Criteria to do a particular query - after an afternoon of consultation with Professor Google, I'm hoping that someone can point me in the right direction.
I have two entities of interest: OutputTsDef and NamedAttribute
What I'm trying to do is to find all OutputTsDef that have a particul...
Hi,
I have a dropdown list on an ASP.NET MVC project that I am pretty sure is not binding to my model because of my nhibernate mapping.
I have tried many variations on the asp mvc side resulting in this post here.
MVC side of things seems fine
I believe the issue may be that my object is trying to bind, but my mapping is out of whack.
...
Entities:
public class Person
{
public Person(){}
public virtual long ID { get; set; }
}
public class Employee : Person
{
public Employee(){}
public virtual long ID { get; set; }
public virtual string Appointment { get; set; }
}
Mappings:
public class PersonMap : ClassMap<Person>
{
public PersonMap()
{
...
What is considered good practice for querying entites from a database using a simple string as a query parameters. Who should implement the method that "converts" the string to an Entity, and who should call this method? The repository, the entity, or some other object, like the controller in an MVC application?
For a more concrete exam...
Hello,
I have 2 entities:
public class Authority : Entity
{
[NotNull, NotEmpty]
public virtual string Name { get; set; }
[NotNull]
public virtual AuthorityType Type { get; set; }
}
public class AuthorityType : Entity
{
[NotNull, NotEmpty]
public virtual string Name { get; set; }
public virtual string Des...
I have two oracle user defined types:
Audit_Type – A normal object with two fields a string and a number
Audit_Table_Type – A table of audit_types, (an array)
I have a stored procedure that takes as a parameter an Audit_Table_Type.
List<Audit_Type> table = new List<Audit_Type>();
var query = session.CreateSQLQuery("call Audit_Rows(A...
Simple question: does it matter which side of a bidirectional many-to-many relationship you set as the inverse in NHibernate? And if so, what are the implications of setting it on one end vs. the other?
Some more clarification: I'm setting both sides of the relationship:
Parent.Children.Add(child);
Child.Parents.Add(parent);
In a cas...
I think I know what the answer to this question is probably going to be, but I thought I'd go ahead and ask it anyway.
It appears that within NHibernate if I do something like this:
IList<Customer> customers = Session.CreateCriteria(typeof(Customer))
.Add(Restrictions.Eq("Name", "Steve")
...
Hello, I have a simple query like:
from e in endContratoRepository.GetAll()
where e.Contrato.idContrato == contrato.idContrato &&
e.Volume.idVolume == 1 &&
group e by new { e.dpto.idDepartamento, e.centroCusto.idCentro...
Dear ladies and sirs.
I want to change the primary key of an entity in database, so that all the relevant foreign key constraints are updated as well./We are using NHibenate as our ORM.
Is it possible to do it?
Thanks.
P.S.
I know the practice of changing the primary key is highly discouraged. My problem is that my primary key is ba...
There are several similar questions on this matter, by I still haven't found enough reasons to decide which way to go.
The real question is, is it reasonable to abstract the NHibernate using a Repository pattern, or not?
It seems that the only reason behind abstracting it is to leave yourself an option to replace NHibernate with a diff...
Hi,
i m starting a new project that would basically take input from user and save them to database among about 30 screens, and i would like to find a framework that will allow the maximum number of these features out of the box :
.net c#.
windows form.
unit testing
continuous integration
logging
screens with lists, combo ...
I am looking for solid non-console examples of how to use ASP.NET MVC1 or MVC2, NHibernate, Fluent NHibernate & Castle. I looked at Sharp Architecture and its just too much to digest for my newbie mind. I need a clean, clear, concise Step A, Step B, Step C tutorial or a solid example that is a web application and not a console applicatio...
When you run into a reserved word like "User" in NHibernate you would just put single quotes around the offending text and nHibernate will surround the text with square brackets for querying. My question is how do you do the same thing using Castle.ActiveRecord?
...
I've made my choice for the developement components on the .NET platform: Spring.NET for IoC and NHibernate for data access. But how safe is it?
I've heard here on SO (don't remember which post exactly) that Spring.NET is on its way down, cause for example the Java original version is developed by a large number of people; but (they say...
What is the meaning of Object Identity Problem in NHibernate?
...
I have a system with a few different databases, and I would like to check if a certain database is down, and if so display a message to the user.
Is it possible in NHibernate to check if there is an active connection to the database, without having to request data and then catch the exception?
...