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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:44:42+00:00 2026-06-13T06:44:42+00:00

I have declared the fallowing mapping with NHibernate3: with FluentNHibernate public class ActivityMap :

  • 0

I have declared the fallowing mapping with NHibernate3:

with FluentNHibernate

public class ActivityMap : ClassMap<Activity> {
    public ActivityMap() {
        this.Table("Activity");
        this.Cache.ReadWrite();
        this.Version(x => x.ObjectVersion);
        this.Id(x => x.Id).GeneratedBy.Assigned();

        // snipp

        this.HasOne(x => x.AppointmentRecurrence).Cascade.Delete();
    }
}

public class AppointmentRecurrenceMap : ClassMap<AppointmentRecurrence> {
    public AppointmentRecurrenceMap() {
        this.Table("AppointmentRecurrence");
        this.Cache.ReadWrite();     
        this.Version(x => x.ObjectVersion);
        this.Id(x => x.Id).GeneratedBy.Foreign("Activity");

        // snipp

        this.HasOne(x => x.Activity).Constrained();
    }
}

which is generating the fallowing hbm-mapping:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class xmlns="urn:nhibernate-mapping-2.2" lazy="false" name="Prayon.Entities.Activity, Prayon.Entities, Version=1.0.0.867, Culture=neutral, PublicKeyToken=null" table="Activity">
    <cache usage="read-write" />
    <id name="Id" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Id" />
      <generator class="assigned" />
    </id>
    <!-- snipp -->
    <one-to-one cascade="delete" class="Prayon.Entities.AppointmentRecurrence, Prayon.Entities, Version=1.0.0.867, Culture=neutral, PublicKeyToken=null" foreign-key="FK_Activity_AppointmentRecurrence" name="AppointmentRecurrence" />
  </class>
</hibernate-mapping>


<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class xmlns="urn:nhibernate-mapping-2.2" lazy="false" name="Prayon.Entities.AppointmentRecurrence, Prayon.Entities, Version=1.0.0.867, Culture=neutral, PublicKeyToken=null" table="AppointmentRecurrence">
    <cache usage="read-write" />
    <id name="Id" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <column name="Id" />
      <generator class="foreign">
        <param name="property">Activity</param>
      </generator>
    </id>
    <!-- snipp -->
   <one-to-one class="Prayon.Entities.Activity, Prayon.Entities, Version=1.0.0.867, Culture=neutral, PublicKeyToken=null" constrained="true" foreign-key="FK_AppointmentRecurrence_Activity" name="Activity" />
  </class>
</hibernate-mapping>

Now, when i select Activities (with a cachable-select), I see in the NHibernate-Profiler, that NHibernate is getting each Activity correct out of the 2nd-Level-Cache, but it will do for each Activity a select to AppointmentReccurrence. What can I do, that it will take the AppointmentReccurrence also from the cache?
I have tried to set a cache-attribute on the one-to-one relationsship, but it seems not be supported.

  • 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-06-13T06:44:44+00:00Added an answer on June 13, 2026 at 6:44 am

    You do seem to have a problem with the Constrained side of your mapping. According to Ayende’s one-to-one guide:

    Something else to note is that we must specify this with foreign-key=”none”, because otherwise NHibernate’s Schema Export feature would create two foreign keys for us, which would create a circular reference that wouldn’t allow us to insert anything into the database.

    Clearly the FK doesn’t actually exist in your database, but the misconfiguration could conceivably cause issues with the cache:

    The way to specify foreign-key="none" in Fluent:

    this.HasOne(x => x.Activity).Constrained().ForeignKey();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the fallowing mapping: <class name=Country table=Country lazy=false > <cache usage=read-write/> <id name=Id
I have declareted the fallowing Mapping for NHibernate: <class name=Sales table=Sales lazy=false > <id
I have the following template method declared in my interface: class IObjectFactory { public:
I have declared a static method in class category public static function getPrefixFromSubCategoyId($subCategoryId) {
I have the declared a class in following way class A: def __init__(self, list_1,
I have declared the following Enum: public enum AfpRecordId { BRG = 0xD3A8C6, ERG
I have declared the following interface in Java: public interface ITest { void doStuff();
Suppose i have declared subscript operators in a class char& operator[] (int index); const
I have this base class having the following interface: abstract class Base { abstract
I have a following class structure: public class A { public bool Property1 {

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.