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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:26:41+00:00 2026-05-15T09:26:41+00:00

im starting whit Nhibernate and have managed to get a few examples working, but

  • 0

im starting whit Nhibernate and have managed to get a few examples working, but now the aplication im makin throws this exeption when Nhibernate load the configuration.

NHibernate.MappingException: An association from the table TBL_MARCADAS refers to an unmapped class: Int32
at NHibernate.Cfg.Configuration.SecondPassCompileForeignKeys(Table table, ISet done)
at NHibernate.Cfg.Configuration.SecondPassCompile()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at BusinessLayer.entidad.inicializar() in D:\vault\BusinessLayer\entidad.vb:line 40
at BusinessLayer.TblEmpleado.getEmpleado(String ci) in D:\vault\BusinessLayer\TblEmpleado.vb:line 60
at BICWEBWS.Service1.get_minutosatraso(String str_CI) in D:\vault\BICWEBWS\App_Code\BICws.asmx.vb:line 7244

here is the entitiy

Imports System.Collections.Generic
Imports System.Text
Imports NHibernate.Collection
Imports NHibernate.Mapping
Imports Iesi.Collections

<NHibernate.Mapping.Attributes.Class(Table:="TBL_MARCADAS")> _
Public Class TblMarcadas
    Inherits entidad
    Private m_codgestion As Integer
    Private m_codperiodo As Integer
    Private m_coddiamarcada As Integer
    Private m_codempleado As Integer
    Private m_codhorario As Integer
    Private m_minAtrasos As Integer
    Private m_cantMarcadas As Integer
    Private m_horaUno As [String]
    Private m_horaDos As [String]
    Private m_horaTres As [String]
    Private m_horaCuatro As [String]
    Private m_horaCinco As [String]
    Private m_horaSeis As [String]
    Private m_diaLiteral As [String]


    Public Sub New()
        'MyBase.entidad()'

    End Sub

    <NHibernate.Mapping.Attributes.CompositeId(0, class:="BusinessLayer.TblMarcadas, BusinessLayer")> _
    <NHibernate.Mapping.Attributes.KeyManyToOne(1, Name:="Codgestion", Column:="CODGESTION")> _
    <NHibernate.Mapping.Attributes.KeyManyToOne(2, Name:="Codperiodo", Column:="CODPERIODO")> _
    <NHibernate.Mapping.Attributes.KeyManyToOne(3, Name:="Coddiamarcada", Column:="CODDIAMARCADA")> _
    <NHibernate.Mapping.Attributes.KeyManyToOne(4, Name:="Codempleado", Column:="CODEMPLEADO")> _
    Public Overridable Property Codgestion() As Integer
        Get
            Return m_codgestion
        End Get
        Set(ByVal value As Integer)
            m_codgestion = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property()> _
    Public Overridable Property Codperiodo() As Integer
        Get
            Return m_codperiodo
        End Get
        Set(ByVal value As Integer)
            m_codperiodo = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property()> _
    Public Overridable Property Coddiamarcada() As Integer
        Get
            Return m_coddiamarcada
        End Get
        Set(ByVal value As Integer)
            m_coddiamarcada = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property()> _
    Public Overridable Property Codempleado() As Integer
        Get
            Return m_codempleado
        End Get
        Set(ByVal value As Integer)
            m_codempleado = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property()> _
    Public Overridable Property Codhorario() As Integer
        Get
            Return m_codhorario
        End Get
        Set(ByVal value As Integer)
            m_codhorario = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="MIN_ATRASOS")> _
    Public Overridable Property MinAtrasos() As Integer
        Get
            Return m_minAtrasos
        End Get
        Set(ByVal value As Integer)
            m_minAtrasos = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="CANT_MARCADAS")> _
    Public Overridable Property CantMarcadas() As Integer
        Get
            Return m_cantMarcadas
        End Get
        Set(ByVal value As Integer)
            m_cantMarcadas = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_UNO")> _
    Public Overridable Property HoraUno() As [String]
        Get
            Return m_horaUno
        End Get
        Set(ByVal value As [String])
            m_horaUno = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_DOS")> _
    Public Overridable Property HoraDos() As [String]
        Get
            Return m_horaDos
        End Get
        Set(ByVal value As [String])
            m_horaDos = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_TRES")> _
    Public Overridable Property HoraTres() As [String]
        Get
            Return m_horaTres
        End Get
        Set(ByVal value As [String])
            m_horaTres = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_CUATRO")> _
    Public Overridable Property HoraCuatro() As [String]
        Get
            Return m_horaCuatro
        End Get
        Set(ByVal value As [String])
            m_horaCuatro = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_CINCO")> _
    Public Overridable Property HoraCinco() As [String]
        Get
            Return m_horaCinco
        End Get
        Set(ByVal value As [String])
            m_horaCinco = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="HORA_SEIS")> _
    Public Overridable Property HoraSeis() As [String]
        Get
            Return m_horaSeis
        End Get
        Set(ByVal value As [String])
            m_horaSeis = value
        End Set
    End Property

    <NHibernate.Mapping.Attributes.Property(Column:="DIA_LITERAL")> _
    Public Overridable Property DiaLiteral() As [String]
        Get
            Return m_diaLiteral
        End Get
        Set(ByVal value As [String])
            m_diaLiteral = value
        End Set
    End Property


    Public Overrides Function Equals(ByVal obj As [Object]) As Boolean
        Return MyBase.Equals(obj)
    End Function

    Public Overrides Function GetHashCode() As Integer
        Return MyBase.GetHashCode()
    End Function

    Public Overrides Function ToString() As String
        Dim s As [String] = ""

        s += "codgestion : " & m_codgestion.ToString() & vbLf
        s += "codperiodo : " & m_codperiodo.ToString() & vbLf
        s += "coddiamarcada : " & m_coddiamarcada.ToString() & vbLf
        s += "codempleado : " & m_codempleado.ToString() & vbLf
        s += "codhorario : " & m_codhorario.ToString() & vbLf
        s += "minAtrasos : " & m_minAtrasos.ToString() & vbLf
        s += "cantMarcadas : " & m_cantMarcadas.ToString() & vbLf
        If m_horaUno IsNot Nothing Then
            s += "horaUno : " & m_horaUno.ToString() & vbLf
        Else
            s += "horaUno : null" & vbLf
        End If
        If m_horaDos IsNot Nothing Then
            s += "horaDos : " & m_horaDos.ToString() & vbLf
        Else
            s += "horaDos : null" & vbLf
        End If
        If m_horaTres IsNot Nothing Then
            s += "horaTres : " & m_horaTres.ToString() & vbLf
        Else
            s += "horaTres : null" & vbLf
        End If
        If m_horaCuatro IsNot Nothing Then
            s += "horaCuatro : " & m_horaCuatro.ToString() & vbLf
        Else
            s += "horaCuatro : null" & vbLf
        End If
        If m_horaCinco IsNot Nothing Then
            s += "horaCinco : " & m_horaCinco.ToString() & vbLf
        Else
            s += "horaCinco : null" & vbLf
        End If
        If m_horaSeis IsNot Nothing Then
            s += "horaSeis : " & m_horaSeis.ToString() & vbLf
        Else
            s += "horaSeis : null" & vbLf
        End If
        If m_diaLiteral IsNot Nothing Then
            s += "diaLiteral : " & m_diaLiteral.ToString() & vbLf
        Else
            s += "diaLiteral : null" & vbLf
        End If
        Return s
    End Function

    Public Overridable Function GetTotalAtrasos(ByVal mes As Integer, ByVal periodo As Integer, ByVal CI As String) As Integer
        ' That's how the Session decide to save or to update; set NHMA.Id(UnsavedValue=x) to replace 0
        Dim session As NHibernate.ISession
        Try
            session = _sessionFactory.OpenSession()

            Dim sd As System.Collections.IList = session.Find("from TBL_MARCADAS")
            Dim total As Integer
            For Each marcada As TblMarcadas In sd
                total += marcada.MinAtrasos
            Next
            Return total
        Catch ex As Exception

        Finally
            If (session IsNot Nothing) Then
                session.Close()
            End If
        End Try
    End Function


End Class

and here is the table Script

CREATE TABLE [dbo].[TBL_MARCADAS](
 [CODGESTION] [int] NOT NULL,
 [CODPERIODO] [int] NOT NULL,
 [CODDIAMARCADA] [int] NOT NULL,
 [CODEMPLEADO] [int] NOT NULL,
 [CODHORARIO] [int] NULL,
 [MIN_ATRASOS] [int] NULL,
 [CANT_MARCADAS] [int] NULL,
 [HORA_UNO] [char](10) NULL,
 [HORA_DOS] [char](10) NULL,
 [HORA_TRES] [char](10) NULL,
 [HORA_CUATRO] [char](10) NULL,
 [HORA_CINCO] [char](10) NULL,
 [HORA_SEIS] [char](10) NULL,
 [DIA_LITERAL] [char](10) NULL,
PRIMARY KEY CLUSTERED 
(
 [CODGESTION] ASC,
 [CODPERIODO] ASC,
 [CODDIAMARCADA] ASC,
 [CODEMPLEADO] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

this is what the NHibernate.mappings serializer throws:

<?xml version="1.0" encoding="utf-8"?>
<!--Generated from NHibernate.Mapping.Attributes on 2010-06-24 08:27:58Z.-->
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
  <class name="BusinessLayer.TblEmpleado, BusinessLayer" table="TBL_EMPLEADO">
    <id name="codempleado">
      <generator class="native" />
    </id>
    <property name="Nombre" />
    <property name="ApellidoP" column="APELLIDO_P" />
    <property name="ApellidoM" column="APELLIDO_M" />
    <property name="FechaIngreso" column="FECHA_INGRESO" />
    <property name="Cargo" />
    <property name="SueldoActual" column="SUELDO_ACTUAL" />
    <property name="Foto" />
    <property name="Estadoempleado" />
    <property name="Codregional" />
    <property name="Codseguro" />
    <property name="Codhorario" />
    <property name="FechaNac" column="FECHA_NAC" />
    <property name="Sexo" />
    <property name="Ci" />
    <property name="Expedido" />
    <property name="Nacionalidad" />
    <property name="TipoTrabajador" column="TIPO_TRABAJADOR" />
  </class>
  <class name="BusinessLayer.TblMarcadas, BusinessLayer" table="TBL_MARCADAS">
    <composite-id class="TblMarcadas">
      <key-many-to-one name="Codgestion" column="CODGESTION" />
      <key-many-to-one name="Codperiodo" column="CODPERIODO" />
      <key-many-to-one name="Coddiamarcada" column="CODDIAMARCADA" />
      <key-many-to-one name="Codempleado" column="CODEMPLEADO" />
    </composite-id>
    <property name="Codperiodo" />
    <property name="Coddiamarcada" />
    <property name="Codempleado" />
    <property name="Codhorario" />
    <property name="MinAtrasos" column="MIN_ATRASOS" />
    <property name="CantMarcadas" column="CANT_MARCADAS" />
    <property name="HoraUno" column="HORA_UNO" />
    <property name="HoraDos" column="HORA_DOS" />
    <property name="HoraTres" column="HORA_TRES" />
    <property name="HoraCuatro" column="HORA_CUATRO" />
    <property name="HoraCinco" column="HORA_CINCO" />
    <property name="HoraSeis" column="HORA_SEIS" />
    <property name="DiaLiteral" column="DIA_LITERAL" />
  </class>
</hibernate-mapping>

thanks very much for your time

  • 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-15T09:26:42+00:00Added an answer on May 15, 2026 at 9:26 am

    Well, i found the problem.

    i dont know why the acutomatic generation tool used key-many-to-one:

    <composite-id class="TblMarcadas">
          <key-many-to-one name="Codgestion" column="CODGESTION" />
          <key-many-to-one name="Codperiodo" column="CODPERIODO" />
          <key-many-to-one name="Coddiamarcada" column="CODDIAMARCADA" />
          <key-many-to-one name="Codempleado" column="CODEMPLEADO" />
        </composite-id>
    

    i just changed it for key-property.

    maybe it was because of a foreign key whit this table?

    any way hope this helps some one bye

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

Sidebar

Related Questions

Starting a project, and this irriating me. I think the code is okay, but
starting with priority_queue s, I have a problem like this: I need elements to
Starting this morning my Eclipse indigo have projects and files with gray light color.
Starting to get my head around makefiles for my C programs, but having some
Starting on my first Metro App and I'm hating this Async crap. I have
Starting to learn Canvas and have two classes so far (main one to call
Starting with a recent new version of ADT, I've noticed this new attribute on
Starting a new rails project and we have a well-thought-out color palette, and want
Starting out with php, I have written a basic authentication script which prints out
Starting out with Windows Azure, but how do I know which is better to

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.