one-to-many

NHibernate eager loading one-to-many

Hi In the mapping-file I've defined a bag for Positionen. <class name="Animag.DomainModels.Models.Abrechnung, Animag.DomainModels" table="Abrechnungen" lazy="true"> <id name="ID" column="ID"> <generator class="native"/> </id> <version name="Version" column="Version"/> <many-to-one name="Kunde" column="KundeID" c...

using fluent-nhibernate, is there convention to make the foreign-key column in one-to-many relation not null ?

I'm using fluent-nhibernate conventions to map my entityies: public class HasManyConvention : IHasManyConvention { public void Apply(FluentNHibernate.Conventions.Instances.IOneToManyCollectionInstance instance) { instance.Key.Column(instance.EntityType.Name + "ID"); instance.Cascade.AllDelete...

Form to create or/and remove a many-to-many relation

Ive got 2 tables, "projects" and "devices". They are connected through a many-to-many relation in the table "projectsdevices". I want to create a form where the 2 can be linked together. For example on the project detail page I have a option "link device". The link device page should show all devices that are available and not yet linked...

Linq to entities - how to select entities with a where condition on their entitycollection ?

Hi all, I found several times people asking for the same question but it seems that the answer was never satisfying altough it should be pretty easy (in theory). Here is my question : I have an entity called "Company" inside which I have an entityCollection "Employees" (one to many). I need to retrieve all Companies and for each of the...

How do I map a has-many collection containing a composite key reference in Fluent NHibernate?

Hello. My schema looks like this: The Message.Id column is an identity(1,1), and the MessageHeader table uses a composite key consisting of the associated message ID, and a header name field that uniquely identifies a header within each message. Entities are represented in code as: public class Message { public virtual int Id {...

NHibernate 3.0 beta1 Bidirectional One-To-Many Cannot Add Child Object

Hi guys, In short, the problem is that, when add child object to the collection property of the parent object without explicit setting the parent property of the child object, the insert will fail. Let's take a example: NOTE: I'm using NHibernate 3.0 beta1. Example: Product-Category Senario: (1) Database Schema: Category (Id, Name)...

Hibernate One To Many Unidirectional Mapping List

Hi, I have one-to-many relationship between parent and child Java objects. The parent object uses java.util.List that stores multiple child objects. The problem I am experiencing is when updating the parent object after I have added one or more child object(s) to the List in the parent. I am using the saveOrUpdate method to save or upda...

Core data Relation Fault (not lazy loading) problem. Relations dissaper

Hello Everyone, I have a core data database which has (for now) 2 entities Product and CompetingProduct, CompetingProduct relation is set to-many with products. I create 2 mock Products and 2 mock Competing products and set relation between them .. everything works files.. Saved to database, also NSlog, "po" them.. all is good. Now.. ...

Hibernate LazyInitializationException: failed to lazily initialize a collection of role

I have a web service which is essentially a wrapper for a DAO. I am calling the web service/DAO to request a collection of entities. The "parent" entity class contains a collection of "child" entity objects, i.e. a one-to-many relationship. The DAO method call which fetches the "parent" entity collection (i.e. myDAO.findAll()) retur...

Calculating relationship density across a 1:n relationship

Hi guys, We have a database of listings that contains 2 million records, each with one or more (of a potential 2500) categories (1:n). Over time, some listings have been added to many irrelevant categories (some listings have as many as 50 categories where we like to keep it below 5.) What I'd love to do is audit each category like so...

data model, many2many with many2one relationship

Hey, I have two types of accounts (customer and provider), I chose the single-table strategy for persistence. Customer creates Orders (one2many) and provider bids on the orders in auction style (many2many relationship, because he can bid on many orders as well as other providers). My question is, is it possible to have these relationship...

using nhibernate ,to delete entity with details cascade-delete-orphan,why do I have to get the entity with all details, in order to delete them too ??

let's say i have the following entities: public class Order { public int OrderID {get;set;}; public int Version {get;set;}; public IList<OrderDetail> Details {get;set;} } public class OrderDetail { public int OrderDetailID {get;set;} /// Some other properties } when i want to delete the entity like this: Order order = ne...

LINQ to SQL: Generating one query when calling First() or Take()

I have a database with the following tables: create table Categories ( Id int primary key, Name nvarchar(256) not null) create table Products ( Id int primary key, Name nvarchar(256) not null, CategoryId int not null, foreign key (CategoryId) references Categories (Id)) Using DataLoadOptions, I can write this: DataLoadOp...