As I was debugging, I saw all the exceptions generated (but in this case all went normal). And I omitted here, but I set some flags within the Catch statement to track errors.
With NHibernate Profiler I detected a error not in this part of code, but in the DAOs used to save the entities. When I changed all the _xxxDao.Save(entity) by _session.Save(entity) all was solved :) Many thanks to all of you that helped me to see better the problem. Rudolf Em terça-feira, 30 de outubro de 2012 09h00min35s UTC-2, Oskar Berggren escreveu: > > That catch clause will in effect hide all exceptions, which is an > excellect way to create a mysterious system. :) Maybe your problem is there. > > Also, the transaction will automatically rollback on dispose if not > committed, so the try-catch can be removed entirely. > > /Oskar > > > 2012/10/30 graffitiMSX <rudolf...@gmail.com <javascript:>> > >> That´s the strange thing. Here is the main transaction block of code: >> >> using (var session = _session.SessionFactory.OpenSession()) >> { >> using (var tx = _session.BeginTransaction()) >> { >> try >> { >> // create the first entity >> Remittance remittance = new Remittance(); >> (...) >> _remittanceDao.Save(remittance); >> (...) >> // create a list with entities >> List<TripSent> tripSentList = new List<TripSent>(); >> for (int i = 0; i < _sepTransactionFile.Details.Count; i++) >> { >> TripSent tripSent = new TripSent(); >> (...) >> tripSentList.Add(tripSent); >> } >> // save the list >> foreach (TripSent tripSent in tripSentList) >> { >> _tripSentDao.Save(tripSent); >> } >> // create final entity >> TransactionFile transactionFile = new TransactionFile(); >> (...) >> _transactionFileDao.Save(transactionFile); >> // commit (and automatically flush) >> tx.Commit(); >> } >> catch >> { >> // problem? Rollback >> tx.Rollback(); >> } >> } >> } >> >> I create the entities, call SAVE() for each and at the end there is a >> Commit() to flush all data do DB. But no INSERT is been generated. >> >> Together with this message I put the results for NHibernate Profiler. >> >> Thanks, >> Rudolf >> >> Em segunda-feira, 29 de outubro de 2012 17h48min33s UTC-2, Brandon Perry >> escreveu: >>> >>> Ensure you are calling transaction.Commit(); >>> >>> On Mon, 2012-10-29 at 12:02 -0700, graffitiMSX wrote: >>> > Hi, >>> > I am trying to save one entity to db using a Transaction,and all the >>> > selects are being executed normally (and logged in on NHibernate >>> > Profiler), but when I call Save(entity) the Insert is not being >>> > generated. My DB is Oracle 11g and the code/mapping follows: >>> > >>> > >>> > Config: >>> > >>> > >>> > DataAccess.Server = "..."; >>> > DataAccess.Username = "..."; >>> > DataAccess.Password = "..."; >>> > DataAccess.ServiceName = "XE"; >>> > DataAccess.Schema = "..."; >>> > DataAccess.Port = 1521; >>> > DataAccess.DataBaseType = DatabaseTypeEnum.Oracle10g; >>> > >>> > string connString = String.Format( >>> > "user id={0};password={1};data source=(DESCRIPTION=(ADDRESS=(** >>> PROTOCOL=tcp)(HOST={2})(PORT={**3}))(CONNECT_DATA=(SERVICE_**NAME={4})))", >>> >>> > Username, Password, Server, Port, ServiceName); >>> > >>> > _sessionFactory = Fluently.Configure() >>> > .Database(**OracleClientConfiguration.**Oracle10 >>> >>> > .ConnectionString(c => c.Is(connString)) >>> > .ShowSql()) >>> > .ExposeConfiguration(c => c.SetProperty("generate_**statistics", >>> "true")) >>> > .Mappings(m => >>> > m.FluentMappings.**AddFromAssembly(Assembly.**GetExecutingAssembly())) >>> >>> > .BuildSessionFactory(); >>> > >>> > ------------------------------**------------------------ >>> > Mapping: >>> > >>> > public RemitMap() >>> > { >>> > Table("EI_REMIT"); >>> > LazyLoad(); >>> > Id(x => x.Id) >>> > .Column("ID") >>> > .CustomType("Int32") >>> > .Access.Property() >>> > .CustomSqlType("NUMBER") >>> > .Not.Nullable() >>> > .Precision(38) >>> > .GeneratedBy.Sequence("EI_**REMIT_ID_SEQ"); >>> > Map(x => x.Sequence) >>> > .Column("SEQUENCE") >>> > .CustomType("Int32") >>> > .Access.Property() >>> > .Generated.Never() >>> > .CustomSqlType("NUMBER") >>> > .Not.Nullable() >>> > .Precision(38); >>> > References(x => x.RemitStatus) >>> > .Class<RemitStatus>() >>> > .Access.Property() >>> > .Cascade.None() >>> > .LazyLoad() >>> > .Columns("EI_REMIT_STATUS_ID")**; >>> > References(x => x.Tag) >>> > .Class<Tag>() >>> > .Access.Property() >>> > .Cascade.None() >>> > .LazyLoad() >>> > .Columns("EI_TAG_ID"); >>> > } >>> > } >>> > ------------------------------**------------------------------**--------------- >>> > >>> >>> > Entity: >>> > >>> > public partial class Remit >>> > { >>> > >>> > private Int32 _Id; >>> > >>> > private Int32 _Sequence; >>> > >>> > private RemitStatus _RemitStatus; >>> > >>> > private Tag _Tag; >>> > >>> > public virtual Int32 Id >>> > { >>> > get >>> > { >>> > return this._Id; >>> > } >>> > set >>> > { >>> > this._Id = value; >>> > } >>> > } >>> > >>> > public virtual Int32 Sequence >>> > { >>> > get >>> > { >>> > return this._Sequence; >>> > } >>> > set >>> > { >>> > this._Sequence = value; >>> > } >>> > } >>> > >>> > public virtual RemitStatus RemitStatus >>> > { >>> > get >>> > { >>> > return this._RemitStatus; >>> > } >>> > set >>> > { >>> > this._RemitStatus = value; >>> > } >>> > } >>> > >>> > public virtual Tag Tag >>> > { >>> > get >>> > { >>> > return this._Tag; >>> > } >>> > set >>> > { >>> > this._Tag = value; >>> > } >>> > } >>> > } >>> > ------------------------------**-------------------------- >>> > Code: >>> > >>> > Remit remit = new Remit(); >>> > remit.Tag = _tagDao.FindById<Tag>("Id", (Int32)_id); >>> > remit.RemitStatus = _remitStatusDao.FindById<**RemitStatus>("Id", >>> (Int32)_remitStatus.Sent); >>> > remit.Sequence = _sequence; >>> > _remitDao.Save(remit); >>> > >>> > ------------------------------**-------------------------- >>> > >>> > That´s all.. >>> > When the 2nd and 3rd lines are being processed, they appear on >>> NHibernate Profiler, but the last line only generates the lines: >>> > >>> > select EI_REMIT_ID_SEQ.nextval >>> > from dual >>> > >>> > And nothing else... >>> > >>> > Thanks for your help! >>> > >>> > Rudolf. >>> > >>> > -- >>> > You received this message because you are subscribed to the Google >>> > Groups "Fluent NHibernate" group. >>> > To view this discussion on the web visit >>> > https://groups.google.com/d/**msg/fluent-nhibernate/-/**vvbI4y2_v2wJ<https://groups.google.com/d/msg/fluent-nhibernate/-/vvbI4y2_v2wJ>. >>> > >>> >>> > To post to this group, send email to >>> > fluent-n...@**googlegroups.com. >>> > To unsubscribe from this group, send email to fluent-nhibernate >>> > +unsub...@googlegroups.com. >>> > For more options, visit this group at >>> > http://groups.google.com/**group/fluent-nhibernate?hl=en<http://groups.google.com/group/fluent-nhibernate?hl=en>. >>> > >>> >>> >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Fluent NHibernate" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/fluent-nhibernate/-/uprs0WrkolIJ. >> To post to this group, send email to >> fluent-n...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> fluent-nhibern...@googlegroups.com <javascript:>. >> For more options, visit this group at >> http://groups.google.com/group/fluent-nhibernate?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To view this discussion on the web visit https://groups.google.com/d/msg/fluent-nhibernate/-/vioIj_b7c6cJ. To post to this group, send email to fluent-nhibernate@googlegroups.com. To unsubscribe from this group, send email to fluent-nhibernate+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en.