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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:30:00+00:00 2026-05-26T08:30:00+00:00

I have such a simple model: public abstract class Entity { public virtual Guid

  • 0

I have such a simple model:

public abstract class Entity
{
    public virtual Guid Id { get; protected set;  }
}

public class Post : Entity
{
    public String Title { get ; set; }
    public String Content { get; set; }
    public DateTime Timestamp { get; set; }
    public Byte[] Thumbnail { get; set; }
}

public class Blog : Entity
{   
    public String Title { get; set; }
    public ISet<Post> Posts { get; set; }
}

Then I have such mappings:

BLOG

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true assembly="Application.Domain" namespace="Application.Domain.Entities">
  <class name="Blog">
    <!-- id generator -->
    <id name="Id">
      <generator class="guid.comb" />
    </id>
  <!-- properties/columns -->
  <property name="Title" not-null="true" />
  <!-- components/columns -->
  <!-- associations -->
  <set name="Posts" cascade="all">
     <!-- key column? -->       
  </set>
  </class>
</hibernate-mapping>

POST

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="Application.Domain" namespace="Application.Domain.Entities">
  <class name="Blog">
    <!-- id generator -->
    <id name="Id">
      <generator class="guid.comb" />
    </id>
    <!-- properties/columns -->
    <property name="Title" not-null="true" />
    <property name="Content" not-null="true" />
    <property name="Timestamp" not-null="true"/>
    <property name="Thmbnail" />
    <!-- components/columns -->
    <!-- associations -->
  </class>
</hibernate-mapping>

How do I map one-to-many association (unidirectional)?

Thanks!

  • 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-26T08:30:00+00:00Added an answer on May 26, 2026 at 8:30 am

    In the blog mapping file you need to define a one-to-many relation between the foreign key column that references the Blog entity in the post table say it is BlogId and you need to tell’em what class this one-to-many relation relates to, in your case this will be the Post class and you need to define it with it’s fully qualified namespace that contains this class and a comma then the assembly name as following:

    <set name="Posts" table="Post">
      <key column="BlogId"/>
      <one-to-many class="Application.Domain.Entities.Post, Application.Domain"/>
    </set>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following model: public class Person { public string Name { get;
If I have a simple class such as:- @XmlRootElement public class MyClass { @XmlAttribute(required=true)
Say I have a simple object such as class Something { public int SomeInt
Let's say I have a regular simple Java class, such as: public class Foo
I have a simple test application: Model: public class Counter { public int Count
I have a simple model: class User < ActiveRecord::Base has_and_belongs_to_many :roles end class Role
Say that I have public static class M { public static string Concat(string a,
I have a model, in the model a method such as, public Pages GetPage(int?
I have only simple data types in method signature of service (such as int,
If I have a simple table where the data is such that the rows

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.