mapping

Should I map a DTO to/from a domain entity on both client and server sides?

I've got a rich domain model, where most classes have some behaviour and some properties that are either calculated or expose the properties of member objects (which is to say that the values of these properties are never persisted). My client speaks to the server only via WCF. As such, for each domain entity, I have a corresponding DT...

Unusual Hibernate inheritence mapping

I've got a curious puzzle with an object-relational mapping, using Java and Hibernate. We have an existing schema that looks something like this: create table foo (id int8, /* ... */ primary key (id)); create table bar (id int8, foo int8, /* ... */ primary key (id)); alter table bar add constraint fk_foobar foreign key (foo) references...

Mapping a DateTime property to a timestamp mysq+fluentnhibernate

I have a little problem with fluentNhibernate and MySQL. I would like to map my entity: public class Topic { public Topic() { ParentTopic = null; } public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual DateTime CreatedAt { get; private set; } public virtual Gui...

Mapping javascript objects to their ids in an MySQL database

Hey all, This is a question that I have been pondering for a long time, but didn't want to ask because I wasn't sure how to describe it.. I'm still not sure if I can describe it well but here it goes.. I have a web app that allows you to manipulate a bunch of elements on the page, but has one save button. When I hit save I would like ...

Mapping a single class to columns in two tables with Fluent nHibernate

I have the following database tables: TABLE dbo.Client ( ClientId PK uniqueidentifier , ClientNames VARCHAR(200) ) TABLE dbo.User ( userID PK UniqueIdentifier, password varchar(15), passwordsalt varchar(15), ClientID FK uniqueidentifier ) I want to map them to my class: public class Client { public virtual Guid Id {...

How do I get the Hibernate reverse engineering tools to generate <bag> or <list> for inverse associations?

I want to add elements to a collection that ends up getting mapped like this: <set name="others" inverse="true" lazy="true" table="other" fetch="select"> <key> <column name="otherId" not-null="true" /> </key> <one-to-many class="my.pkg.OtherEntity" /> </set> I'd like Hibernate to use instead, because I don't care about the ...

NHibernate Mapping a Collection with a Discriminator

Let's say that I have a class/table called Images that, as it stands right now, is bound in a manner similar to this: <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> <class name="Domain.Image, Domain" table="Images"> <id name="id" column="ImageID" access="field" unsaved-value="0"> <generator class="identity" /> </...

String and character mapping question for the guru's out there....

Here's a problem thats got me stumped (solution wise): Given a str S, apply character mappings Cm = {a=(m,o,p),d=(q,u),...} and print out all possible combinations using C or C++. The string can be any length, and the number of character mappings varies, and there won't be any mappings that map to another map (thus avoiding circular d...

nhibernate mapping, join without primary and foreign keys

I have these legacy tables which i’m accessing by nhibernate, basic one entity access is fine but i would really need to get joins working. Ideally i would have primary and foreign key to define the joins but as these are legacy tables i only have composite ids that are the indexes for the tables, indexes these have been used for perfor...

NHibernate mapping

Hello, I have question :-) How to map this class [Serializable] public class AgentSourceCounter { private int agentId; private IDictionary<int, int> sourceCounters; protected AgentSourceCounter() { } public AgentSourceCounter(int agentId, Dictionary<int, int> sourceCounters) { this.agentId = agentI...

Web-based UI element for selecting a geographical location

I'd like to create / use a UI element for a web-site that provides a world map, on which the user can draw a circle to indicate an area of interest. I'd like information on the coordinates of the area covered by the circle to be available to me via Javascript for sending back to the server over Ajax. Does such a control exist, and if no...

iPhone OpenGL Texture loader issues

Ok, what I'm trying to achieve is to load an image as a single resource and then save different parts of it as a number of different textures (basically chopping the image into smaller squares and then saving them separately). For my game, simply mapping different sections of the original image to my shapes won't work and being able to ...

NHibernate - Mapping one property to two or more fields?

I have a database table that includes a two bit fields: IsEvenSide and IsOddSide. I want this to map to the following enum: [Flags] enum SideOfStreet { None, Even, Odd } I have done IUserType's in the past, but I don't know how to map to multiple database fields. How can this be done? P.S.: I'm using Fluent NHibernate, but I'm okay ...

JPA+Hibernate - Reconnecting entities from a @OneToMany relationship

Hello everybody. Consider the following simple example: One team has many players and a player may only belong to one team. @Entity public class Team { @OneToMany(cascade = CascadeType.ALL, mappedBy = "team") @Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORP...

Entity Framework - How do I join tables on non-primary key columns in secondary tables?

I want to join 2 tables using entity framework. I want the join to the second table to be on a non-primary key column. e.g. I have a table Foo with fields Foo.Id (PK) Foo.DbValue and table Bar Bar.Id (PK) Bar.DbValue Bar.Description And I want to join Foo to Bar in EF on the DbValue field. In hibernate/nhibernate one can do this...

IndexOutOfRangeException Deep in the bowels of NHibernate

I have the following mappings: public class SecurityMap : ClassMap<Security> { public SecurityMap() { Table("Security"); CompositeId().KeyProperty(k => k.Id, "SecurityId").KeyProperty(k => k.EndDate); Map(x => x.LastUpdateUser); References(x => x.Company).Columns("Compa...

NHibernate mapping problem

Hello, I have a table like: CREATE TABLE [dbo].[MOVIES_HISTORY]( [DATE] [datetime] NOT NULL, [COUNT] [int] NOT NULL CONSTRAINT [DF_MOVIES_HISTORY_COUNT] DEFAULT ((0)), CONSTRAINT [PK_MOVIES_HISTORY] PRIMARY KEY CLUSTERED ( [DATE] ASC )WITH (PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] Class: using System;...

NHibernate mapping. Set collection of joined-subclass declared elements and the where property.

I am working on a project where persisted data can be flagged for deletion, but remains in the database having a column (is_deleted) set to TRUE. This works fine using the hibernate class mapping property "where" and adding where="is_deleted = 0" to the tags. But it fails when I declare a set of sub-class elements. This simplified exam...

Mapping an array of records with depth values into nested Unordered List

Hi there, I hope this question hasn't been asked before: I'm using the ancestry gem to manage my tree structure. I'm using a function which returns the descendants of a node to a certain number of levels. Here's a simplistic example of what it's returning: [{:name => 'node 1', :depth => 1}, {:name => 'node 2', :depth => 2} {:name => '...

Subsonic table mappings

I've searched a lot and I haven't really found an answer. Is it possible to use POCOs with Subsonic? How do I map tables (which do not look like the POCOs) to my classes? ...