POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE
PAGE!On 22 Jan 2008 17:15, Nandem wrote:
>what exactly are you guys saving ?
>just one object ?
>well...
>there a many reasons to nHibernate not saving new instances.
>maybe are in
>try { } catch(Exception) { }
>and you cant see the error throws,
>maybe (if u're using <many-to-one unique="true"> tag on hibernate, and
>this object will be saved if u use property (cascade="save-update").
>if in session.FlushMode is setted to FlushMode.Never
>call a session.flush() before call commitTransaction (maybe it works!)
>try change session.FlushMode options.
>are to many reasons for it not work.
>Post the code, and maybe some guy will help ya
>good luck!
I had a situation where althrough I called session.flush() the changes
weare not in the database. after some research i found that where I cal
session.flush() then the querys are runned against the jdbc driver. Here
rezides the problem (if this could be called problem) jdbc connection
was not autocomiting. so, as a hack, I wrote this:
public Session getSession()
{
if(session == null)
{
session = sessionFactory.openSession();
session.setFlushMode(FlushMode.ALWAYS);
try {
//here my connection is autocomiting
session.connection().setAutoCommit(true);
} catch (SQLException e) {
LOG.error("Can't set connection autocomit");
}
}
return session;
}
But I read that your data is dissapiring when ypu restart the
application. hmmm... maybe you set
<property name="hibernate.hbm2ddl.auto">create</property>
on startup hibernate confiruration ...
just check! |