-->
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.  [ 1 post ] 
Author Message
 Post subject: More than two fields in an entity class.
PostPosted: Mon Jun 14, 2010 10:42 am 
Newbie

Joined: Mon Jun 14, 2010 10:23 am
Posts: 1
I am new to Nhibernate and I am trying to connect to iSeries and insert records on a table. I am using Nhibernate.Mapping.Attributes for dynamically map entities. When I use only two fields, all is working:

[NHibernate.Mapping.Attributes.Class(Table = "datos2", NameType = typeof(Datos2))]
public class Datos2
{

[NHibernate.Mapping.Attributes.Id(Name = "Autoincrem")]
[NHibernate.Mapping.Attributes.Column(Name = "Autoincrem")]
[NHibernate.Mapping.Attributes.Generator(0, Class = "native")]
public virtual int Autoincrem
{ get; set; }

[NHibernate.Mapping.Attributes.Property(1, Name = "Dato1")]
[NHibernate.Mapping.Attributes.Column(Name = "Dato1")]
virtual public int Dato1 { get; set; }


}

But, when I add this code to the class:


[NHibernate.Mapping.Attributes.Property(2, Name = "Dato2")]
[NHibernate.Mapping.Attributes.Column(Name = "Dato2")]
virtual public int Dato2 { get; set; }

And the code runs the instruction “session.save(datos2)” I receive the next Exception:

[InvalidCastException: El tipo de datos devuelto no está soportado actualmente por el proveedor.]
IBM.Data.DB2.iSeries.iDB2DbTypeUtility.MapSQLTypeToDCPCType(DcSqlTypes sqlType, Int32 colccsid, UInt32 length) +750
IBM.Data.DB2.iSeries.iDB2Command.setRowOfParameterData(MpDcData[]& dcDataRow) +1664
IBM.Data.DB2.iSeries.iDB2Command.execute() +595
IBM.Data.DB2.iSeries.iDB2Command.ExecuteNonQuery() +274
NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) +63
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) +992

[ADOException: could not insert: [TestAlgo+Datos2][SQL: INSERT INTO datos2 (Dato1, Dato2, Autoincrem) VALUES (?, ?, default)]]
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session) +1525
NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session) +404
NHibernate.Impl.ScheduledIdentityInsertion.Execute() +132
NHibernate.Impl.SessionImpl.Execute(IExecutable executable) +210
NHibernate.Impl.SessionImpl.DoSave(Object theObj, EntityKey key, IEntityPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything) +1130
NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IEntityPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything) +564
NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything) +482
NHibernate.Impl.SessionImpl.Save(Object obj) +313
TestAlgo.Page_Load(Object sender, EventArgs e) in c:\temp\NHibernateTest\TestAlgo.aspx.cs:60
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207


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

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.