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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:29:37+00:00 2026-05-26T11:29:37+00:00

I have a collection mapped to an array and it appears to work fine.

  • 0

I have a collection mapped to an array and it appears to work fine. But when I load the itens from database, the first element of the array is always null. Is there a way to avoid this?

The mapping of the owner of the array:

public class ConsistMap : BaseEntityMap<Consist>
    {
        public ConsistMap():
            base("consist_id")
        {
            Not.LazyLoad();

            Map(x => x.RemoveEmptyCars).Not.Nullable();

            HasMany(x => x.ConsistVehicles)
                .Inverse()
                .AsArray<int>(x => x.Position)
                .Cascade.AllDeleteOrphan()
                .OrderBy("position asc")
                .KeyColumn("consist_id");
        }
    }

And the elements mapping:

public class ConsistVehicleMap : BaseEntityMap<ConsistVehicle>
    {
        public ConsistVehicleMap():
            base("consist_vehicle_id")
        {
            Not.LazyLoad();

            Map(x => x.Position).Not.Nullable();

            References(x => x.Consist).Not.Nullable();

            HasMany(x => x.Tickets)
                .Inverse()
                .Cascade.None()
                .KeyColumn("consist_vehicle_id");

            References(x => x.Vehicle)
                .Column("vehicle_id")
                .Not.Nullable();
        }
    }

Any ideas why when the Consist object is created the first element of the ConsistVehicles array is null? I checked the data on the database and the only rows on the table are the elements stored on the array.

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-26T11:29:37+00:00Added an answer on May 26, 2026 at 11:29 am

    Just a guess: you are probably starting Position at 1 instead of 0.

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

Sidebar

Related Questions

I have a RestKit-based app with one mapped class. Everything seems to work fine.
I have Collection List<Car> . How to compare each item from this collection with
I have a collection of classes that inherit from an abstract class I created.
I have a class that contains a collection that is mapped to a many-to-many
I have an class which has a collection, mapped as a bag in my
I have recently started using automapper and it has work fine for me so
I have a class called SynonymMapping which has a collection of values mapped as
I have a collection mapped as a query only property following Ayende's example .
i have this POJO mapped to my MySQL database: @Entity @Table(name = participantespresentes, catalog
I have an entity that is mapped with a <join> element like this: <class

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.