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 7171329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T15:23:34+00:00 2026-05-28T15:23:34+00:00

Suppose I have a class with a collection of immutable types, that I would

  • 0

Suppose I have a class with a collection of immutable types, that I would like to map with a custom ICompositeUserType

public class Foo
{
    public long Id { get; protected set; }

    public virtual IList<Bar> Bars { get; set; }
}

//immutable
public class Bar
{
    private _blah;
    private _halb;

    public Bar(string blah, string halb)
    {
        _blah = blah; _halb = halb;
    }

    public Blah { get { return _blah; } }
    public Halb { get { return _halb; } }
}

How do I set up the mapping of the bag on Foo to use a composite user type, so that the custom type can invoke the constructor when necessary?

I tried this, but type isn’t available on composite-element.

<bag name="Bars" table="FooBars" lazy="true">
   <key column="FooId" foreign-key="FK_Bars_FooId" />
   <composite-element class="Doman.Bar, Domain" type="Integration.UserTypes.BarCompositeUserType, Integration">
       <property name="Blah">
          <column name ="BarBlah" sql-type="char(2)"/>
       </property>
   </composite-element>
</bag>

However, that won’t work because NHibernate does not recognize the “type” attribute on “composite-element”

How to I map a bag with an ICompositeUserType? (I am using NHibernate 3.2)

  • 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-28T15:23:35+00:00Added an answer on May 28, 2026 at 3:23 pm

    element instead of composite-element because the properties and conversion is specified inside the ICompositeUserType

    <element type="Integration.UserTypes.BarCompositeUserType, Integration">
      <column name="BarBlah" />
      <column name="BarHalb" />
    </element>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have a collection of Foo classes: class Foo { public string Bar;
Suppose I have a custom collection class that provides some internal thread synchronization. For
Suppose I have an entity in Fluent NHibernate that looks like this: public class
Suppose I have: class Foo { ... }; class Bar : public Foo {
Suppose I have an array or any other collection for that matter in class
Suppose I have the following classes: class X; class Y; class Collection { public:
Suppose I have class Foo(db.Model): bar = db.ReferenceProperty(Bar) foo = Foo.all().get() Is there a
Suppose I have class A { public: void print(){cout<<A; }}; class B: public A
Suppose I have a class public class MyClass { private Set<String> set = new
Suppose I have: public class foobar { public int lorem; public int ipsum; }

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.