---------------
var domainClasses = typeof(EntidadeBase).Assembly.GetTypes().Where(t
=> typeof(EntidadeBase).IsAssignableFrom(t));
return mapper.CompileMappingFor(domainClasses);
---------------
how could I add the ViewBase?
Is it possible to I set the EntityBase as Nullable, and the ViewBase
as NotNullable?
mapper.AddPropertyPattern(mi => orm.IsRootEntity(mi.DeclaringType), pm
=> pm.NotNullable(true));
On Dec 16, 9:57 am, Arthur Helfstein Fragoso <art...@life.net.br>
but to you understand what is happening here, I have a table where I
can only select (read-only, a SQL View)
NHibernate selects my table and gives me the result. Everything is
fine.
but then, when I use the ISession.Flush() from NHibernate, it tries to
do an update in that table. I don't know if I mapped something wrong
or if I configurated nhbernate wrong.
I have other tables, but this is the only table that is trying to
update on Flush()
Is this the right place to I ask about this problem, if not, could you
inform where I could get help?
my mapping file: http://pastebin.com/La3jcMZV
the Error I'm getting, I show it with NotNullable set true, and then
NotNullable set false to you see that it's trying to do an update in
the table, but it shouldn't. The select is working alright, but it
should never do an update n this table.
The error I'm getting when I set NotNullable(true));
NHibernate: SELECT viewassina0_.id as id4_0_,... viewassina0_ WHERE
viewassina0_.id=:p0;:p0 = 29471 [Type: Int64 (0)]
NHibernate.PropertyValueException : not-null property references a
null or transient value
Central.Dominio.Views.ViewAssinante.ComplementoResidencial
at NHibernate.Engine.Nullability.CheckNullability(Object[] values,
IEntityPersister persister, Boolean isUpdate)
at
NHibernate.Event.Default.DefaultFlushEntityEventListener.ScheduleUpdate(FlushEntityEvent
event)
at
NHibernate.Event.Default.DefaultFlushEntityEventListener.OnFlushEntity(FlushEntityEvent
event)
at
NHibernate.Event.Default.AbstractFlushingEventListener.FlushEntities(FlushEvent
event)
at
NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent
event)
at
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event)
at NHibernate.Impl.SessionImpl.Flush()
at Central.Repositorio.RepositorioViewSessao`1.Dispose() in
RepositorioViewSessao.cs: line 42
at Central.TesteUnitario.View.TesteViewAssinante.PodeRetornarPeloId()
in TesteViewAssinante.cs: line 31
-------------------------------------------------------
When I set NotNullable(false));
NHibernate: select viewassina0_.id as id4_,... from
central.vis_assinantes_web viewassina0_ where viewassina0_.email like
('%'||:p0||'%');:p0 = 'a' [Type: String (0)]
8326
NHibernate: UPDATE central.vis_assinantes_web SET cidaderesidencial
= :p0, estadoresidencial = :p1, ... :p34 = NULL [Type: String
(0)], :p35 = NULL [Type: String (0)], :p36 = NULL [Type: String
(0)], :p37 = NULL [Type: String (0)], :p38 = 'Carlos 018 3356 1223
014 96760291 - Eliane
Filiação:
J--- da Silva
L--- da Silva' [Type: String (0)], :p39 = 'Sim' [Type: String
(0)], :p40 = NULL [Type: String (0)], :p41 = NULL [Type: String
(0)], :p42 = 25144 [Type: Int64 (0)]
NHibernate.Exceptions.GenericADOException : could not update:
[Central.Dominio.Views.ViewAssinante#25144][SQL: UPDATE
central.vis_assinantes_web SET cidaderesidencial = ?,
estadoresidencial = ?, codassinante = ?, cpfcnpj = ?, inscrestrg = ?,
nomeassinante = ?, logradouroresidencial = ?, numeroresidencial = ?,
complementoresidencial = ?, quadraresidencial = ?, bairroresidencial
= ?, blocoresidencial = ?, aptoresidencial = ?, andarresidencial = ?,
edificioresidencial = ?, cepresidencial = ?, datanascimento = ?, email
= ?, profissao = ?, estadocivil = ?, logradourocobranca = ?,
numerocobranca = ?, complementocobranca = ?, bairrocobranca = ?,
nomecidade = ?, nomeestado = ?, cepcobranca = ?, diavencimento = ?,
formapagamento = ?, taxacompensacao = ?, bancocobranca = ?,
agenciacredito = ?, contacredito = ?, agenciadebito = ?, contadebito
= ?, titularconta = ?, cpftitular = ?, outrasinformacoes = ?,
observacao = ?, enviarboletoemail = ?, nomepai = ?, nomemae = ? WHERE
id = ?]
----> Npgsql.NpgsqlException : ERROR: 55000: cannot update view
"vis_assinantes_web"
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object
id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
includeProperty, Int32 j, Object oldVersion, Object obj,
SqlCommandInfo sql, ISessionImplementor session)
at
NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object
id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
includeProperty, Int32 j, Object oldVersion, Object obj,
SqlCommandInfo sql, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object
id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection,
Object[] oldFields, Object oldVersion, Object obj, Object rowId,
ISessionImplementor session)
at NHibernate.Action.EntityUpdateAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource
session)
at
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent
event)
at NHibernate.Impl.SessionImpl.Flush()
at Central.Repositorio.RepositorioViewSessao`1.Dispose() in
RepositorioViewSessao.cs: line 42
at
Central.TesteUnitario.View.TesteViewAssinante.PodeConsultarPorNome()
in TesteViewAssinante.cs: line 54
--NpgsqlException
at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
at Npgsql.ForwardsOnlyDataReader.GetNextResponseObject()
at Npgsql.ForwardsOnlyDataReader.GetNextRowDescription()
at Npgsql.ForwardsOnlyDataReader.NextResult()
at Npgsql.ForwardsOnlyDataReader..ctor(IEnumerable`1 dataEnumeration,
CommandBehavior behavior, NpgsqlCommand command,
NotificationThreadBlock threadBlock, Boolean synchOnReadError)
at Npgsql.NpgsqlCommand.GetReader(CommandBehavior cb)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation
expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object
id, Object[] fields, Object[] oldFields, Object rowId, Boolean[]
includeProperty, Int32 j, Object oldVersion, Object obj,
SqlCommandInfo sql, ISessionImplementor session)