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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:37:31+00:00 2026-05-11T13:37:31+00:00

In my model I have Games. Each Game has an Event associated with it,

  • 0

In my model I have Games. Each Game has an Event associated with it, which is mapped as a many-to-one association.

When I query for Games, within event with given EventId (different than its DB-PrimaryKey-id) NHibernate issues the following query for each and every Game:

NHibernate: SELECT event0_.Id as Id8_0_, event0_.EventId as EventId8_0_ FROM Events event0_ WHERE event0_.EventId=@p0; @p0 = '4' 

In my mapping (and in the DB generated from the mapping) EventId has a Unique constraint. How do I tell NHibernate that it should fetch the Event only once for given EventId, not issue the same exact query N times for N Games?

  • 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-11T13:37:31+00:00Added an answer on May 11, 2026 at 1:37 pm

    Fixed. The problem was that foreign key was set on non-primary key of the ‘one’ table. Changing that fixed the issue.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Game model which has_many Rounds which has_many Shots. Per game, each
I have the following models: Game and Pick. There's a one to many association
I have written a checkers game model which has a Board object that holds
I have this query in model: public function Games() { $q = $this->db->select('games.id, games.title,
I have model with a location, which itself has a latitude and longitude. What
I have model Foo which has field bar. The bar field should be unique,
My app has a User model, and a Game model. I want each user
I have a model, Game , which has_many :piles . In fact, I know
I have two activities. One activity has the main game and the other activity
I am making a game, and have a Game model and a User model.

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.