Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:00:15+00:00 2026-05-11T04:00:15+00:00

I’m using NHibernate and Fluent NHibernate to create a mapping file for a domain

  • 0

I’m using NHibernate and Fluent NHibernate to create a mapping file for a domain object (though I don’t care if an answer uses fluent NHibernate or xml hbm syntax). And I’m having trouble with figuring out how I specify that a set of columns representing a component within the domain object is unique.

Here’s the domain object:

public class SpaceLocation {         public SpaceCoordinate Coordinates { get; set; }         public SpaceObject AtLocation { get; set; } } 

and here is the component I’m having trouble with:

public struct SpaceCoordinate {         public int x { get; set; }         public int y { get; set; }         public int z { get; set; } } 

Don’t worry about SpaceObject AtLocation for the purposes of this quesiton.

So I know how to make a component out of SpaceCoordinate, but I want to make it so that there cannot be duplicate inserts of the same set of Coordinates. In order to do this, I want to make the component as a whole unique.

To give you a sense of the direction I’m trying to go, I’ll show you what I have for the mapping class:

public class SpaceLocationMap : ClassMapWithGenerator<SpaceLocation>     {         public SpaceLocationMap()         {              Component<SpaceCoordinate>(x => x.Coordinates, m =>              {                 m.Map(x => x.x);                 m.Map(x => x.y);                 m.Map(x => x.z);             });         }     } 

The problem with this Fluent NHibernate mapping is that it does not apply the unique constraint to the SpaceCoordinate’s values collectively. Mind you I’m not trying to set each as unique individually, that would be too restrictive.

So how would you map with this with a hbm or fluent map file?

Any help would be greatly appreciated, Thanks for reading!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T04:00:16+00:00Added an answer on May 11, 2026 at 4:00 am

    m4bwav was correct with the hbm mapping; however, Fluent NHibernate didn’t have support for this at the time you wrote your question. I’ve just committed a fix that adds a Unique method to the component mapping.

    Component<SpaceCoordinate>(x => x.Coordinates, m =>  {   m.Map(x => x.x);   m.Map(x => x.y);   m.Map(x => x.z); }).Unique(); 

    So you’ll need to update your copy of Fluent NHibernate. If you’re unable to do this for some reason, you could use the SetAttribute method to hack it.

    Component<SpaceCoordinate>(x => x.Coordinates, m =>  {   m.Map(x => x.x);   m.Map(x => x.y);   m.Map(x => x.z); }).SetAttribute('unique', 'true'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
In order to apply a triggered animation to all ToolTip s in my app,
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.