mapping

How to implement table-per-concrete-type strategy using entity framework

I'm mapping a set of tables that share a common set of fields: So as you can see I'm using a table-per-concrete-type strategy to map the inheritance. But... I have not could to relate them to an abstract type containing these common properties. It's possible to do it using EF? BONUS: The only non documented Entity Data Model Map...

Map different child foreign key columns based on parent type at runtim

I think I probably know that the most common suggestion will be "change the database schema" but unfortunately it's one of those "I'm stuck with a legacy database" situations. Basically I want to map the following using Fluent NHibernate CREATE TABLE Person (PersonId int) CREATE TABLE Organisation (OrganisationId int) CREATE TABLE Ow...

Fluent Nhibernate Many-to-Many mapping with extra column

I want to map sth like this using fluent Nhibernate but I am not sure how to map the inventory table This is the tables I have : Product (Id,Name, ...) Warehouse(Id, Name, ...) Inventory(Product_id, Warehouse_id, StockInHand) I have map the Product and Warehouse like below Public ProductMap() { Id(x => x.Id); ...

How do I map to a parent or child in the same table with NHibernate?

Lets suppose that I have a Category table with a column that holds the id of a parent or child category from the same table. This design would allow me to have unlimited levels of Categories, or unlimited levels in a thread, for example. How can I map this relationship with NHibernate? Are there any disadvantages or warnings that I shou...

Need help with NHibernate / Fluent NHibernate mapping

Let's say your have the following table structure: ============================== | Case | ============================== | Id | int | | ReferralType | varchar(10) | +---------| ReferralId | int ...

Hibernate mapping, on a unmapped class

Hi, I' ve got 2 tables... Challenge and ChallengeYear, ChallengeYear is only to create a list of years in challenge. I only want to make Challenge an entity, containing a list of List years. Is this possible? I've looked in to @SecondaryTable together with @JoinColumn and @OneToMany, but neither of those can do the trick, or i am ove...

Parent Key Column Type Change in Many-to-Many Mapping

I have a join table where the original table is a numeric type and the join table key column is a string type. Legacy decision that I am trying to avoid having to change to minimize the risk to the scope of work. HasManyToMany<Attachment>(x => x.Attachments) .Table("ObjectAttachments") .ParentKeyColumn("ObjectId") .ChildKeyColumn...

How to map IDictionary<string, object> in Fluent NHibernate?

I am looking to persist user preferences into a collection of name value pairs, where the value may be an int, bool, or string. There are a few ways to skin this cat, but the most convenient method I can think of is something like this: public class User { public virtual IDictionary<string, object> Preferences { get; set; } } wit...

Castle ActiveRecord: Map to IUserType wihtin Class in C#

Hi *, for my current project I am using Castle's ActiveRecord in C#. For one of my tables I do need to use a custom type class (dealing with an stupid time to timespan conversion). To keep my code clean I like to define the class which is derived from IUserType within the object mapping class. But I can find no way to map this property ...

NHibernate - illegal access to loading collection error

I'm getting the error "Illegal acces to loading collection" when i'm trying to get a list of variants belonging to a certain product. The NHibernate mapping is as below; <list name="Variants" lazy="false" cascade="save-update" inverse="false" table="PluginProduct_ProductVariant"> <key column="ProductId" /> <index column="Ordinal" />...

Duplicate Items Using Join in NHibernate Map

I am trying to retrieve the individual detail rows without having to create an object for the parent. I have a map which joins a parent table with the detail to achieve this: Table("UdfTemplate"); Id(x => x.Id, "Template_Id"); Map(x => x.FieldCode, "Field_Code"); Map(x => x.ClientId, "Client_Id"); Join("UdfFields", join => { join....

Hibernate: can I override an identifier generator using XML with a custom generator?

I want to use a custom sequence generator in my application, but the entity is located in a domain model jar that is shared with other applications. Apparently entity annotations can be overridden in orm.xml but I can't figure out the proper XML incantation to get this to work. I can modify the annotation in the entity like this this: ...

How to create mapping for a List<SomeNativeType> in FluentNhibernate ?

Hi all, I am trying to create a mapping file for the following Model using Fluent NHibernate. But, I am not sure of how to do the mapping for the List<string> in the mapping file. public class MyClass { public virtual Guid Id { get; set; } public virtual string Name { get; set; } public virtual List<stri...

Foreign key not stored in child entity (one-to-many)

Hi, I'm quite new to hibernate and have stumbled on this problem, which I can't find solution for. When persisting parent object (with one-to-many relationship with child), the foreign-key to this parent is not stored in child's table. My classes: Parent.java @javax.persistence.Table(name = "PARENT") @Entity public class PARENT { p...

How do i generate hubernate models for java dotCMS plugins

Hi I am trying to create a plugin for dotCMS. My plugin stores data in database. i defined hibernate mapping file and put in my plugin folder's conf dir and i have no idea how to hibernate generate models based my mapping definition. I am using hello world plugin's mapping file for mysql Any help or comment would be highly appreciated ...

Is there a better way than a sequence of if's to handle events?

I recently ran across several objects implemented to handle events with a hard coded mapping using this pattern: public void handleEvent(Event event) { if(event.getCode() == SOME_STATIC_EVENT) doSomething(event); if(event.getCode() == ANOTHER_STATIC_EVENT) doSomethingElse(event); } where doSomething functions a...

PHP XML Strategy: Parsing DOM to fill "Bean"

I have a question concerning a good strategy on how to fill a data "bean" with data inside an xml file. The bean might look like this: class Person { var $id; var $forename = ""; var $surname = ""; var $bio = new Biography(); } class Biography { var $url = ""; var $id; } the xml subtree containing the info might look lik...

nhibernate mapping: delete collection, insert new collection with old IDs

my issue lokks similar to this one: (link) but i have one-to-many association: <set name="Fields" cascade="all-delete-orphan" lazy="false" inverse="true"> <key column="[TEMPLATE_ID]"></key> <one-to-many class="MyNamespace.Field, MyLibrary"/> </set> (i also tried to use ) this mapping is for Template object. this one and the Field...

Transform GPS Co-Ordinates to Container Co-Ordinates.

Hi, I am looking for some service that can transform GPS coordinates into XY coordinates so that I can plot a point on an Image. Something like fromLatLngToContainerPixel would be great. Thanks in advance. P.S. I am developing a desktop application in java. ...

Hibernate won't save into database

I mapped some classes to some tables with hibernate in Java, i set Hibernate to show SQL, it opens the session, it shows that it does the SQL, it closes the session but there are no modifications to the database. Entity public class Profesor implements Comparable<Profesor> { private int id; private String nume; private String prenume; ...