-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: could not compile mapping
PostPosted: Tue Aug 07, 2007 7:21 am 
Newbie

Joined: Tue Aug 07, 2007 7:14 am
Posts: 3
when I use AddAsembly it accuse an error in my mapping

could not compile mapping



Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="MagicShop.Dados.ObjetosPersistencia.Produtosaidacancelado,MagicShop.Dados.ObjetosPersistencia" table="produtosaidacancelado">

      <id name="PscId" column="psc_id" type="Int32" unsaved-value="0">
         <generator class="native"/>
      </id>
      <many-to-one name="PrsId" column="prs_id" class="MagicShop.Dados.ObjetosPersistencia.Produtosaida,MagicShop.Dados.ObjetosPersistencia" />
      <property column="dtcancelado" type="DateTime" name="Dtcancelado" not-null="true" />
      <property column="motivo" type="String" name="Motivo" not-null="true" length="255" />
      
   </class>
</hibernate-mapping>


Code:

using System;
using System.Collections;

namespace MagicShop.Dados.ObjetosPersistencia
{
   /// <summary>
   ///   Generated by MyGeneration using the NHibernate Object Mapping template
   /// </summary>
   [Serializable]
   public sealed class Produtosaidacancelado
   {

      #region Private Members
      private bool _isChanged;

      private int _psc_id;
      private Produtosaida _prs_id;
      private DateTime _dtcancelado;
      private string _motivo;       
      #endregion

      #region Default ( Empty ) Class Constuctor
      /// <summary>
      /// default constructor
      /// </summary>
      public Produtosaidacancelado()
      {
         _psc_id = 0;
         _prs_id = new Produtosaida();
         _dtcancelado = DateTime.MinValue;
         _motivo = String.Empty;
      }
      #endregion // End of Default ( Empty ) Class Constuctor

      #region Required Fields Only Constructor
      /// <summary>
      /// required (not null) fields only constructor
      /// </summary>
      public Produtosaidacancelado(
         Produtosaida prs_id,
         DateTime dtcancelado,
         string motivo)
         : this()
      {
         _prs_id = prs_id;
         _dtcancelado = dtcancelado;
         _motivo = motivo;
      }
      #endregion // End Required Fields Only Constructor

      #region Public Properties
         
      /// <summary>
      ///
      /// </summary>
      public int PscId
      {
         get { return _psc_id; }
         set
         {
            _isChanged |= ( _psc_id != value );
            _psc_id = value;
         }

      }
         
      /// <summary>
      ///
      /// </summary>
      public Produtosaida PrsId
      {
         get { return _prs_id; }
         set
         {
            if( value == null )
               throw new ArgumentOutOfRangeException("Null value not allowed for PrsId", value, "null");

            _isChanged |= ( _prs_id != value );
            _prs_id = value;
         }

      }
         
      /// <summary>
      ///
      /// </summary>
      public DateTime Dtcancelado
      {
         get { return _dtcancelado; }
         set
         {
            _isChanged |= ( _dtcancelado != value );
            _dtcancelado = value;
         }

      }
         
      /// <summary>
      ///
      /// </summary>
      public string Motivo
      {
         get { return _motivo; }

         set   
         {   
            if( value == null )
               throw new ArgumentOutOfRangeException("Null value not allowed for Motivo", value, "null");
            
            if(  value.Length > 255)
               throw new ArgumentOutOfRangeException("Invalid value for Motivo", value, value.ToString());
            
            _isChanged |= (_motivo != value); _motivo = value;
         }
      }
         
      /// <summary>
      /// Returns whether or not the object has changed it's values.
      /// </summary>
      public bool IsChanged
      {
         get { return _isChanged; }
      }
            
      #endregion
   }
}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 07, 2007 7:32 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

Wouldn't the problem be in the format of the classname ?

I mean: you're using
Code:
<class name="MagicShop.Dados.ObjetosPersistencia.Produtosaidacancelado,MagicShop.Dados.ObjetosPersistencia" table="produtosaidacancelado">


But the part after the komma should be your assembly name. So assuming your assembly name is 'MagicShop.dll' that should become:

Code:
<class name="MagicShop.Dados.ObjetosPersistencia.Produtosaidacancelado,MagicShop" table="produtosaidacancelado">


The same applies for your many-to-one mapping.

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 7:12 am 
Newbie

Joined: Tue Aug 07, 2007 7:14 am
Posts: 3
Hi!

Ok, now I have this error:

*I am generating the mapiamento with MyGeneration*

Code:
The following types may not be used as proxies:
MagicShop.Dados.ObjetosPersistencia.Cidade: method get_CddId should be virtual
MagicShop.Dados.ObjetosPersistencia.Compracancelada: method set_CompracanceladaList should be virtual
MagicShop.Dados.ObjetosPersistencia.Produto: method get_Nome should be virtual
MagicShop.Dados.ObjetosPersistencia.Cliente: type should not be sealed
MagicShop.Dados.ObjetosPersistencia.Cliente: method get_Maladireta should be virtual
MagicShop.Dados.ObjetosPersistencia.Fornecedor: method set_Cnpjcpf should be virtual
MagicShop.Dados.ObjetosPersistencia.Compracancelada: method set_CmpId should be virtual
MagicShop.Dados.ObjetosPersistencia.Produtoestoque: method get_Quantidade should be virtual
MagicShop.Dados.ObjetosPersistencia.Compra: method get_Endrnumero should be virtual
MagicShop.Dados.ObjetosPersistencia.Magiccard: method get_MgdId should be virtual
MagicShop.Dados.ObjetosPersistencia.Produtosaida: method set_PstId should be virtual
MagicShop.Dados.ObjetosPersistencia.Endereco: method get_ClienteList should be virtual
MagicShop.Dados.ObjetosPersistencia.Magicedicao: method set_MgdId should be virtual
MagicShop.Dados.ObjetosPersistencia.Compracancelada: method set_Dtcancelamento should be virtual
MagicShop.Dados.ObjetosPersistencia.Compracancelada: method set_Motivo should be virtual
MagicShop.Dados.ObjetosPersistencia.Endereco: method get_Tipo should be virtual
MagicShop.Dados.ObjetosPersistencia.Magicedicao: method get_Dtedicao should be virtual
MagicShop.Dados.ObjetosPersistencia.Produtoestoque: method set_FncnId should be virtual
MagicShop.Dados.ObjetosPersistencia.Cliente: method get_EndrId should be virtual
...
...
...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 7:20 am 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

Or:
- you declare your class as being lazy='false', effectively turning off lazy loading for that class:
f.e.
Code:
<class name="MagicShop.Dados.ObjetosPersistencia.Produtosaidacancelado,MagicShop" table="produtosaidacancelado" lazy="false">

Which I wouldn't do, if I were you !

Or:
you must declare all your non-private properties and methods as being virtual.

(there is a third option that disables this check entirely, but that's not a good idea).

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 1:03 pm 
Newbie

Joined: Tue Aug 07, 2007 7:14 am
Posts: 3
I declared in class "lazy='false'" and works!

thanks!

But, now I have this error:

Code:
Could not create the driver from NHibernate.Driver.MySqlDataDriver.


Code:
The IDbCommand and IDbConnection implementation in the assembly MySql.Data could not be found. Ensure that the assembly MySql.Data is located in the application directory or in the Global Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element in the application configuration file to specify the full name of the assembly.



In my Web.confg I put this:
Code:
<add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
    <add key="hibernate.dialect" value="NHibernate.Dialect.MySQL5Dialect" />
    <add key="hibernate.connection.driver_class" value="NHibernate.Driver.MySqlDataDriver" />
    <add key="hibernate.connection.connection_string" value="Database=magicshop;Data Source=localhost;User Id=root;Password=xxxxxxx;" />



And I add Reference the Mysql.Data for .NET


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 08, 2007 2:19 pm 
Regular
Regular

Joined: Thu Nov 23, 2006 10:29 am
Posts: 106
Location: Belgium
Hi,

I suppose the exception stems from the fact that the mySQL dataprovider .dll isn't found in the bin directory.

In your project, check the properties of your reference to that mySQL dataprovider and make sure Copy Local=true (this should put the .dll along with the other assemblies in the deployment directory). I might be wrong about this, I'm not a web developer. Just give it a try.

_________________
Please rate this post if it helped.

X.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.