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

  • SEARCH
  • Home
  • 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 602983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:52:55+00:00 2026-05-13T16:52:55+00:00

I have a class LINE which contains two properties of type POINT. I would

  • 0

I have a class LINE which contains two properties of type POINT.
I would like POINT to be a component property.
If LINE were to contain only 1 POINT, this would be no problem, but since it contains 2 POINTs I would think I needed to distinguish them (so a prefix or suffix can be applied to column names).
I tried using the PropertyName attribute of the ComponentProperty tag, but still only one set of X and Y columns is generated inside my LINE table.

For clarity, my goal is to have a LINE table with a Point1_X, Point1_Y, Point2_X and a Point2_Y column.

I use Nhibernate.Mapping.Attributes, below you can see my mapping

[Class]
public class Line : EntityBase
{
  [ComponentProperty(PropertyName = "Point1")]
  public UiPoint Point1 { get; set; }

  [ComponentProperty(PropertyName = "Point2")]
  public UiPoint Point2 { get; set; }

  //omitted the constructor

}

[Component]
public class UiPoint
{
  [Property]
  public double X { get; set; }

  [Property]
  public double Y { get; set; }

  //omitted the constructor 
}

In the meanwhile I figured out the following XML mapping wil solve my problem

<class name="Domain.WashProcessLine,Domain">
    <id name="Id" />
    <component name="Point1">
       <property name="X" type="Double" column="Point1_X" />
       <property name="Y" type="Double" column="Point1_Y" />
    </component>
    <component name="Point2">
        <property name="X" type="Double" column="Point2_X" />
        <property name="Y" type="Double" column="Point2_Y" />
    </component>
</class>

found an option on https://www.hibernate.org/hib_docs/nhibernate/html/components.html

the following tagging creates the desired table structure, but does give me a casting exception (from UiPoint to IDictionary) when retreiving the property from the database.

So I’m not entirely there yet 🙁

[Class]
public class Line : EntityBase
{
    [DynamicComponent(1)]               
    [Property(2, Name = "X", Column = "Point1_X", TypeType = typeof(double))]
    [Property(3, Name = "Y", Column = "Point1_Y", TypeType = typeof(double))]
    public UiPoint Point1 { get; set; }

    [DataMember]
    [DynamicComponent(1)]               
    [Property(2, Name = "X", Column = "Point2_X", TypeType = typeof(double))]
    [Property(3, Name = "Y", Column = "Point2_Y",TypeType=typeof(double))]
    public UiPoint Point2 { get; set; }
}
  • 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. Editorial Team
    Editorial Team
    2026-05-13T16:52:55+00:00Added an answer on May 13, 2026 at 4:52 pm

    After looking at the unit tests for Nhibernate.Mapping.Attributes, and trying a number of different solutions, we found that the cleanest way (unfortunately) to fix the situation provided above, was by injecting some raw xml into our mapping. This means we removed the property attributes in our line class and replaced them with a single entry as shown below

    [RawXml(After=typeof(ComponentAttribute), Content = @"<component name=""Point1"">
    <property name=""X"" type=""Double"" column=""Point1_X"" />
       <property name=""Y"" type=""Double"" column=""Point1_Y"" />
    </component>
    <component name=""Point2"">
        <property name=""X"" type=""Double"" column=""Point2_X"" />
        <property name=""Y"" type=""Double"" column=""Point2_Y"" />
    </component>")]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that contains two arraylists which I'm trying to store objects
I have a class Type which cannot be copied nor it contains default constructor.
I'm wondering something. I have class Polygon , which composes a vector of Line
I have a class class ChartLine{ protected: vector<Point> line; // points connecting the line
I have a script which contains two classes. (I'm obviously deleting a lot of
I have a Class, which contains inner class. I want to send value, which
I have an abstract base class which contains a private nested implementation. visual c++
Let's say I have a table which can contains data like this: id name
I have a wrapper <div> which contains two inner <div> s that are floating.
I have a typical, Post model: class Post< ActiveRecord::Base validates_presence_of :user_id #Line 1 validates_presence_of

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.