hbm

Nhibernate One-to-one mapping issue with child object insert error

Hi, i've being banging my head against the desk all day with the following Nhibernate problem. Each bank account has one (and only one) set of rates associated with it. The primary key of the bank account table, BankAccountID is also a foreign key and the primary key in the AccountRate table. public class BankAccount { public virtu...

Changing the Hibernate 3 settings

I use Hibernate3 and Hibernate Tools 3.2.4 to generate hbm.xml and java files and I want to use List instead of HashSet(...). I've tried to modify the hbm.xml files, putting list instead of set. Is there any way to specify to hibernate tools that I want to generate automatically a list not a HashSet? This is an exemple: Java class publ...

Using nHibernate to map two different data models to one entity model

I have two different data models that map to the same Car entity. I needed to create a second entity called ParkedCar, which is identical to Car (and therefore inherits from it) in order to stop nhibernate complaining that two mappings exists for the same entity. public class Car { protected Car() { IsParked = false; ...

NHibernate: Filtering a child collection which includes a join

I have the following mapping files: <?xml version="1.0" encoding="utf-8"?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MyAssembly" namespace="EntityNamespace"> <class name="Server" xmlns="urn:nhibernate-mapping-2.2" table="tblServer" > <id name="Id" type="int"> <generator class="native"...

Doing table per subclass using a discriminator with NHibernate.Mapping.Attributes

I'm trying to do Table per subclass: using a discriminator using NHibernate.Mapping.Attributes. The hbm should look like this: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <subclass name="SalesReport" discriminator-value="SalesReport" extends="Report"> <join table="SalesReport"> <key foreign-key="FK_SalesReport_Doc...

Hibernate Many-To-Many HBM Mapping

How would I generate the hbm file for the following scenario? In particular, I'm having trouble modeling the many-to-many relationship's composite key..... Table: Course Primary Key: CourseId Table: Enrollment Primary Key: CourseId, StudentId Table: Fees Primary Key: FeeId Other Columns: Amount, Description Table: Enrollment_Has_Fees...

Nhibernate - Mapping many to many dictionary

I have the following classes: public class A { public virtual int Id { get; private set; } public virtual IDictionary<MyEnum, B> MyBValues { get; set; } } public class B { public virtual int Id { get; private set; } } public enum MyEnum { Value1, Value2, Value3 } And would like the following tables: A ------------...

How to map Sets when using NHibernate Join Table per Subclass

I have the following HBMs (the sample is purely fictional, so don't try to understand the business needs) Class Document <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Document" discriminator-value="Document"> <id name="Id" type="long"> <generator class="native" /> </id> <discriminator /> <p...

Generating Hibernate composite key object from hbm file

(Parenthetical rant:) I'm a Hibernate beginner getting slightly frustrated by the overhead of a simple join that I could write in 15 seconds in SQL. (End rant) The situation is thus: I have 2 tables that both contain the same composite primary key - let's call the columns in both tables 'ID' and 'Version'. I need data about a particula...

How to export hbm xml files using s#arparchitecture with fluent mappings

This question was asked before but the answers all show how to export the hbm files from fluentnhibernate. We are using S#arpArchitecture which wraps fluent. I am able to export the schema but what I really want is the xml files to troubleshoot errors. I've done this using FNH before but adding S#arp to the mix has complicated things wh...

How to override S#arp architecture automapping with HBM files?

I'm facing problems with composite keys in S#arp architecture. Anyone have an example of how to do that or how to use mapping files with automapping? ...

How to visualize NHibernate hbm.xml files

Are there any tools or clever methods for me to I visualize the contents of NHibernation hbm.xml files? I would like to load hbm files into a designer and see them as entities with relations ...

Hibernate HBM one-to-many

I have a one-to-many relationship and in my HBM I want to include the association for delete purposes. How can I express that without query/loading the related table/object? Just including a bag or another collection is the obvious answer, but is there something else? Hibernate 2.2 ...

NHibernate slow startup, conditional loading of HBMs and "Association references unmapped class"

Background We have several projects / applications running off the same model. They all have their own unique entities / tables, but also share 1 specific, common entity / table. I.e. Entities required by application A, will never be required by application B, except for the common table, and vice versa. Now the common table has relatio...

How to run Nhibernate ICriteria query with setFetchMode(Lazy) when lazy=false defined in HBM?

Hi all, I'd like to run a criteria query with lazy many-to-one associations. Those associations are set as lazy="false" in the HBM. It's because we use it eagerly 90% of the project. But there are a few 'big' queries that should run as lazy="proxy". HBM: <many-to-one name="DestinationElement" class="X" column="DstElemId" not-null="tr...

can you re-use nhibernate mapping files for tables with common columns

We have a bunch of lookup tables that all share the same columns (ID,Code,Description, etc) and my co-worked just asked me if we could build a generic lookup.hbm.xml mapping file and use it as a base for all the other lookup tables. Does nhibernate support include files, or some other way to reference a common chunk of XML? I understan...

NHibernate Property Mapping, best practise for type attribute?

I have a little doubt for mapping of property in hbm file. Sometimes I've mapped the string field of my db in this way: <property name="MyPropName" column="MyColumnName" length="20" /> but the same mapping can be wrote in this way: <property name="MyPropName" column="MyColumnName" type="String(20)" /> my question is...what's the b...