-->
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.  [ 7 posts ] 
Author Message
 Post subject: beginner error (could not update error)
PostPosted: Thu May 18, 2006 9:29 am 
Newbie

Joined: Thu May 18, 2006 8:55 am
Posts: 4
i created a nhibernate project with all the classes and files, and when i use session.load for a single object everything works fine, but when i want to get a list (either using icriteria.list or iquery list (session.CreateCriteria(typeof(Lica)).List()) and i get a could not update error [class_name#2], and innerexception is sqldatetime overflow. and this is for a simple list of all the rows in a table.
below is the stack trace and the code
pls help :)



Hibernate version:1.0.2

Code:
NHibernate.Cfg.Configuration cfg = new NHibernate.Cfg.Configuration();
cfg.AddAssembly("dal");
NHibernate.ISessionFactory sf = cfg.BuildSessionFactory();
NHibernate.ISession s = sf.OpenSession();
Repeater1.DataSource = s.CreateCriteria(typeof(Lica)).List();
Repeater1.DataBind();

******

StackTrace " at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Object oldVersion, Object obj, SqlString sqlUpdateString, ISessionImplementor session)\r\n at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)\r\n at NHibernate.Impl.ScheduledUpdate.Execute()\r\n at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)\r\n at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)\r\n at NHibernate.Impl.SessionImpl.Execute()\r\n at NHibernate.Impl.SessionImpl.AutoFlushIfRequired(ISet querySpaces)\r\n at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria)\r\n at NHibernate.Impl.CriteriaImpl.List()\r\n at _Default.Page_Load(Object sender, EventArgs e) in e:\\My Documents\\Visual Studio 2005\\WebSites\\sotac_web\\Default.aspx.cs:line 39\r\n at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)\r\n at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)\r\n at System.Web.UI.Control.OnLoad(EventArgs e)\r\n at System.Web.UI.Control.LoadRecursive()\r\n at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)" string

SQL Server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 21, 2006 6:01 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
post the mapping and the class definition files.

cheers,
radu


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 3:25 am 
Newbie

Joined: Thu May 18, 2006 8:55 am
Posts: 4
also, i cannot insert or update any row. the only thing that works is loading single rows via session.load


class:

/*
insert license info here
*/
using System;

namespace dal
{
/// <summary>
/// Generated by MyGeneration using the NHibernate Object Mapping adapted by Gustavo
/// </summary>
[Serializable]
public class Lica
{
#region Private Members
private bool _isChanged;
private bool _isDeleted;
private decimal _lic_id;
private Dpz _dpz_id;
private Sifarnik2 _sf2_sifra;
private Posta _pos_id;
private Dpz _dpz_dpz_id;
private Dpz _dpz_dpz_id2;
private Roditelj _rod_id;
private Roditelj _rod_rod_id;
private string _lic_jmbg;
private string _lic_prezime;
private string _lic_ime;
private string _lic_roditelj;
private string _lic_djevojacko;
private DateTime _lic_dat_rod;
private string _lic_adr;
private string _lic_br_lk;
private string _lic_mjesto_rod;
private string _lic_telefon;
private string _lic_napomena;
private string _lic_telefond;
private DateTime _lic_dat_pasiva;
private Guid _rowguid;
private decimal? _lic_reon;
private decimal? _lic_banka;
private string _lic_partija;
private decimal? _lic_bracni_status;
private string _lic_mjesto_lk;
#endregion

#region Default ( Empty ) Class Constuctor
/// <summary>
/// default constructor
/// </summary>
public Lica()
{
_lic_id = 0;
_dpz_id = null;
_sf2_sifra = null;
_pos_id = null;
_dpz_dpz_id = null;
_dpz_dpz_id2 = null;
_rod_id = null;
_rod_rod_id = null;
_lic_jmbg = null;
_lic_prezime = null;
_lic_ime = null;
_lic_roditelj = null;
_lic_djevojacko = null;
_lic_dat_rod = DateTime.MinValue;
_lic_adr = null;
_lic_br_lk = null;
_lic_mjesto_rod = null;
_lic_telefon = null;
_lic_napomena = null;
_lic_telefond = null;
_lic_dat_pasiva = DateTime.MinValue;

_lic_reon = null;
_lic_banka = null;
_lic_partija = null;
_lic_bracni_status = null;
_lic_mjesto_lk = null;
}
#endregion // End of Default ( Empty ) Class Constuctor

#region Public Properties

/// <summary>
///
/// </summary>
public virtual decimal LicId
{
get { return _lic_id; }
set { _isChanged |= (_lic_id != value); _lic_id = value; }
}

/// <summary>
///
/// </summary>
public virtual Dpz DpzId
{
get { return _dpz_id; }
set { _isChanged |= (_dpz_id != value); _dpz_id = value; }
}

/// <summary>
///
/// </summary>
public virtual Sifarnik2 Sf2Sifra
{
get { return _sf2_sifra; }
set { _isChanged |= (_sf2_sifra != value); _sf2_sifra = value; }
}

/// <summary>
///
/// </summary>
public virtual Posta PosId
{
get { return _pos_id; }
set { _isChanged |= (_pos_id != value); _pos_id = value; }
}

/// <summary>
///
/// </summary>
public virtual Dpz DpzDpzId
{
get { return _dpz_dpz_id; }
set { _isChanged |= (_dpz_dpz_id != value); _dpz_dpz_id = value; }
}

/// <summary>
///
/// </summary>
public virtual Dpz DpzDpzId2
{
get { return _dpz_dpz_id2; }
set { _isChanged |= (_dpz_dpz_id2 != value); _dpz_dpz_id2 = value; }
}

/// <summary>
///
/// </summary>
public virtual Roditelj RodId
{
get { return _rod_id; }
set { _isChanged |= (_rod_id != value); _rod_id = value; }
}

/// <summary>
///
/// </summary>
public virtual Roditelj RodRodId
{
get { return _rod_rod_id; }
set { _isChanged |= (_rod_rod_id != value); _rod_rod_id = value; }
}

/// <summary>
///
/// </summary>
public virtual string LicJmbg
{
get { return _lic_jmbg; }
set
{
if ( value != null)
if( value.Length > 13)
throw new ArgumentOutOfRangeException("Invalid value for LicJmbg", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicPrezime
{
get { return _lic_prezime; }
set
{
if ( value != null)
if( value.Length > 30)
throw new ArgumentOutOfRangeException("Invalid value for LicPrezime", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicIme
{
get { return _lic_ime; }
set
{
if ( value != null)
if( value.Length > 30)
throw new ArgumentOutOfRangeException("Invalid value for LicIme", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicRoditelj
{
get { return _lic_roditelj; }
set
{
if ( value != null)
if( value.Length > 30)
throw new ArgumentOutOfRangeException("Invalid value for LicRoditelj", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicDjevojacko
{
get { return _lic_djevojacko; }
set
{
if ( value != null)
if( value.Length > 30)
throw new ArgumentOutOfRangeException("Invalid value for LicDjevojacko", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual DateTime LicDatRod
{
get { return _lic_dat_rod; }
set { _isChanged |= (_lic_dat_rod != value); _lic_dat_rod = value; }
}

/// <summary>
///
/// </summary>
public virtual string LicAdr
{
get { return _lic_adr; }
set
{
if ( value != null)
if( value.Length > 40)
throw new ArgumentOutOfRangeException("Invalid value for LicAdr", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicBrLk
{
get { return _lic_br_lk; }
set
{
if ( value != null)
if( value.Length > 20)
throw new ArgumentOutOfRangeException("Invalid value for LicBrLk", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicMjestoRod
{
get { return _lic_mjesto_rod; }
set
{
if ( value != null)
if( value.Length > 20)
throw new ArgumentOutOfRangeException("Invalid value for LicMjestoRod", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicTelefon
{
get { return _lic_telefon; }
set
{
if ( value != null)
if( value.Length > 20)
throw new ArgumentOutOfRangeException("Invalid value for LicTelefon", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicNapomena
{
get { return _lic_napomena; }
set
{
if ( value != null)
if( value.Length > 1000)
throw new ArgumentOutOfRangeException("Invalid value for LicNapomena", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual string LicTelefond
{
get { return _lic_telefond; }
set
{
if ( value != null)
if( value.Length > 20)
throw new ArgumentOutOfRangeException("Invalid value for LicTelefond", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual DateTime LicDatPasiva
{
get { return _lic_dat_pasiva; }
set { _isChanged |= (_lic_dat_pasiva != value); _lic_dat_pasiva = value; }
}

/// <summary>
///
/// </summary>
public virtual Guid Rowguid
{
get { return _rowguid; }
set { _isChanged |= (_rowguid != value); _rowguid = value; }
}

/// <summary>
///
/// </summary>
public virtual decimal? LicReon
{
get { return _lic_reon; }
set { _isChanged |= (_lic_reon != value); _lic_reon = value; }
}

/// <summary>
///
/// </summary>
public virtual decimal? LicBanka
{
get { return _lic_banka; }
set { _isChanged |= (_lic_banka != value); _lic_banka = value; }
}

/// <summary>
///
/// </summary>
public virtual string LicPartija
{
get { return _lic_partija; }
set
{
if ( value != null)
if( value.Length > 16)
throw new ArgumentOutOfRangeException("Invalid value for LicPartija", value, value.ToString());

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

/// <summary>
///
/// </summary>
public virtual decimal? LicBracniStatus
{
get { return _lic_bracni_status; }
set { _isChanged |= (_lic_bracni_status != value); _lic_bracni_status = value; }
}

/// <summary>
///
/// </summary>
public virtual string LicMjestoLk
{
get { return _lic_mjesto_lk; }
set
{
if ( value != null)
if( value.Length > 20)
throw new ArgumentOutOfRangeException("Invalid value for LicMjestoLk", value, value.ToString());

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

/// <summary>
/// Returns whether or not the object has changed it's values.
/// </summary>
public bool IsChanged
{
get { return _isChanged; }
}

/// <summary>
/// Returns whether or not the object has changed it's values.
/// </summary>
public bool IsDeleted
{
get { return _isDeleted; }
}

#endregion


#region Public Functions

/// <summary>
/// mark the item as deleted
/// </summary>
public void MarkAsDeleted()
{
_isDeleted = true;
_isChanged = true;
}


#endregion


#region Equals And HashCode Overrides
/// <summary>
/// local implementation of Equals based on unique value members
/// </summary>
public override bool Equals( object obj )
{
if( this == obj ) return true;
if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
Lica castObj = (Lica)obj;
return ( castObj != null ) &&
( this._lic_id == castObj.LicId );
}

/// <summary>
/// local implementation of GetHashCode based on unique value members
/// </summary>
public override int GetHashCode()
{

int hash = 57;
hash = 27 * hash * _lic_id.GetHashCode();
return hash;
}
#endregion

}
}



<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="dal.Lica,dal" table="LICA" lazy="true">

<id name="LicId" column="LIC_ID" type="Decimal" unsaved-value="0">
<generator class="assigned"/>
</id>
<many-to-one name="DpzId" column="DPZ_ID" class="dal.Dpz,dal" />
<many-to-one name="Sf2Sifra" column="SF2_SIFRA" class="dal.Sifarnik2,dal" />
<many-to-one name="PosId" column="POS_ID" class="dal.Posta,dal" />
<many-to-one name="DpzDpzId" column="DPZ_DPZ_ID" class="dal.Dpz,dal" />
<many-to-one name="DpzDpzId2" column="DPZ_DPZ_ID2" class="dal.Dpz,dal" />
<many-to-one name="RodId" column="ROD_ID" class="dal.Roditelj,dal" />
<many-to-one name="RodRodId" column="ROD_ROD_ID" class="dal.Roditelj,dal" />
<property column="LIC_JMBG" type="String" name="LicJmbg" length="13" />
<property column="LIC_PREZIME" type="String" name="LicPrezime" length="30" />
<property column="LIC_IME" type="String" name="LicIme" length="30" />
<property column="LIC_RODITELJ" type="String" name="LicRoditelj" length="30" />
<property column="LIC_DJEVOJACKO" type="String" name="LicDjevojacko" length="30" />
<property column="LIC_DAT_ROD" type="DateTime" name="LicDatRod" />
<property column="LIC_ADR" type="String" name="LicAdr" length="40" />
<property column="LIC_BR_LK" type="String" name="LicBrLk" length="20" />
<property column="LIC_MJESTO_ROD" type="String" name="LicMjestoRod" length="20" />
<property column="LIC_TELEFON" type="String" name="LicTelefon" length="20" />
<property column="LIC_NAPOMENA" type="String" name="LicNapomena" length="1000" />
<property column="LIC_TELEFOND" type="String" name="LicTelefond" length="20" />
<property column="LIC_DAT_PASIVA" type="DateTime" name="LicDatPasiva" />
<property column="rowguid" type="Guid" name="Rowguid" not-null="true" />
<property column="LIC_REON" type="Decimal" name="LicReon" />
<property column="LIC_BANKA" type="Decimal" name="LicBanka" />
<property column="LIC_PARTIJA" type="String" name="LicPartija" length="16" />
<property column="lic_bracni_status" type="Decimal" name="LicBracniStatus" />
<property column="lic_mjesto_lk" type="String" name="LicMjestoLk" length="20" />

</class>
</hibernate-mapping>
[/url]


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 3:58 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
The "datetime overflow" error generally happens when you forget to initialize a DateTime property. In this case it's saved with the default value of 01/01/0001 which SQL Server cannot represent.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 4:43 am 
Newbie

Joined: Thu May 18, 2006 8:55 am
Posts: 4
where to change the default date, in mapping file?
and do u think that is the only problem here, is that the reason neither update or save with the database dont work?


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 5:44 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It's not possible to change it in the mapping file, you have to make sure that your date is set to a valid value in your C# code. If you want to be able to set the date to NULL, you have to use a nullable date/time type (SqlDateTime or NullableDateTime on .NET 1.1). Support for nullable dates is part of NHibernateContrib package.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 8:23 am 
Newbie

Joined: Thu May 18, 2006 8:55 am
Posts: 4
ok, more questions :)

i'm using .net 2.0, which has nullable support, as i understood the documentation.
and, i added values in database for all involved tables for datetime columns, and no datetime is null and i still receive the same error. any chance of fixing it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.