entity property that is nullable
I want my nhibernate entity property to be nullable. the column is a nvarchar(MAX) in sql server, and it can be NULL. How do I map this using the xml mapping? ...
I want my nhibernate entity property to be nullable. the column is a nvarchar(MAX) in sql server, and it can be NULL. How do I map this using the xml mapping? ...
Consider this 3 classes public class ClassA { public IList<ClassB> BList {get; private set;} } public class ClassB { public ClassC C {get; private set;} } public ClassC { //doesn't matter } I want to get all ClassA instances from the repository, that has at least one BList element containing a specific C instance, that i...
I'm using schemaExport to create an in-memory database for my automatic tests. I have several (5) classes mapping their HiLo identity to the same database table, using one column per class. This gives me a table, hibernate_unique_key, w. 5 columns. When generating the database using scemaexport, however, the table only gets a single col...
I have a inheritance hierarchy which I have mapped in NHibernate using Table-per-class. My mappping file looks like the one below (lots of properties omitted). To query this hierarchy, I am building a dynamic DetachedCriteria for Message based on filter input from the user. Messages (of any type in the hierarchy) should be returned to t...
Hi, I have the following problem. I have a special column in my tables (a blob). In order to read and write to that column, I need to call an SQL function on its value - to convert to a string when I read, and to convert from a string to this blob when I write. The read part is easy - I can use a formula to run the sql function agains...
I've got two entities, one called Site and the other called Assignment. A Site may or may not have an associated Assignment. An Assignment is only ever associated with one Site. In terms of C#, Site has a property of type Assignment which could hold a null reference. I have got two tables by the same names in the database. The Assignmen...
Hi, I'm thinking of building a ecommerce application with an extensible data model using NHibernate and Fluent NHibernate. By having an extensible data model, I have the ability to define a Product entity, and allow a user in the application to extend it with new fields/properties with different data types including custom data types. ...
i want to write to database table which has composite id using NHibernate.This is the code that i used.but it didnt work. <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="NHibernatePets.junctionstatistic, NHibernatePets" lazy="true"> <composite-id> <key-property name="junction...
I have a c# library for my web application where I am using nhibernate. The web application has the hibernate.cfg.xml file where I set: current_session_context_class = web I am using a nhibernateHelper class and a httpmodule to open and close the session on a per request basis. I now need to use this library in a console application, ...
When paging data, I want to not only return 10 results, but I also want to get the total number of items in all the pages. How can I get the total count AND the results for the page in a single call? My paged method is: public IList GetByCategoryId(int categoryId, int firstResult, int maxResults) { IList<Article> arti...
I'm new to NHibernate and Fluent NHibernate. I'm wondering how to properly use Fluent NHibernate with the "table per subclass" mapping strategy. This is an example of what I'm after. More specifically though, I need a way to break the subclass mappings into separate files. Also, when adding records, I need NHibernate to first insert in...
from my previous question: http://stackoverflow.com/questions/1947026/multiple-results-in-a-single-call how would I get the count of all articles in a given category? I prefer criteria query if possible (would love it if you could show me how to do it in both criteria and hql) ...
Hi experts, I have a legacy VB6 app which I am rewriting in .Net. I have not used an ORM package before (being the old fashioned type who likes to know what SQL is being used), but I have seen good reports of NNibernate and I am tempted to use it for this project. I just want to check I won't be shooting myself in the foot. Because my ...
my create query (HQL) looks like: Session.CreateQuery( "select a from Article as a join a.Categories c where c.ID = :ID") .SetInt32("ID", categoryId) ...
Have the following entities in my domain: Project Task User Context A user can have multiple projects, tasks and contexts. A project can have tasks and contexts and a task can have contexts. I am a little unsure as how best to model Contexts as it will belong to multiple entities i.e. a user can add a list of contexts, these context...
Can someone please give me an example of what the mappings would look like for two classes that both have composite keys and a one-to-many relationship? I have looked everywhere and tried 100 different things with no luck. E.g., HeaderTable -HCONO Decimal -HDVNO Decimal -HDTTK Decimal -HDES2 String -HDESC String -HDESC3 String HCO...
Hi, Is there a way to use SessionFactory.GetClassMetadata(), or any other method you're aware of, to dynamically get the maximum size of a varchar column that underlies an NHibernate class' string property? To clarify, I'm not looking to read a length attribute that's specified in the NHibernate mapping file. I want to deduce the actu...
I want to manage SQL Server dynamically, that is through code I wan to scan SQL Server for available databases than I want to create new database, access older database, alter it, and insert data into database depending upon table schema what is better approach what should I use? i heard name of nhibernate, SQL Server Management Object ...
I have an object that has many assocations to other objects. All of these are fetched lazily by nHibernate, which is good in almost all cases. In a particular scenario, in this case an export of a lot of records, I want to set the Fetchmode to eager on all associations. Is there a way to do this, without having to manually specify each...
I have a database that accepts no null values and has a default for every field. Using fluent nHibernate, I am getting an error on an Insert if I have a component that has some, but not all properties filled out. I am just wondering how to get the DynamicInsert flag down to the component level. Perhaps it is late, but I'll just drop t...